Friday 12 January 2018

How to check the year is leap year or not | Java 8 LocalDate Class | Java 8 Date and Time


Click here to watch on Youtube : 
https://www.youtube.com/watch?v=kvbtYlH6-pg&list=UUhwKlOVR041tngjerWxVccw

LocalDateDemo.java

import java.time.LocalDate;

public class LocalDateDemo
{

    public static void main(String[] args)
    {
        LocalDate date1 = LocalDate.of(2017, 9, 25);

        /*
         * Returns:true if the year is leap, false otherwise
         */

        System.out.println(date1.isLeapYear());

        LocalDate date2 = LocalDate.of(2020, 9, 25);
        System.out.println(date2.isLeapYear());
    }

}

Output

false
true

Click the below link to download the code:
https://sites.google.com/site/ramj2eev1/home/javabasics/LocalDateDemo_isLeapYear.zip?attredirects=0&d=1

Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/LocalDateDemo_isLeapYear

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/7d1a1b8046fa2c6f340631d1f5b0f99be87e7675/BasicJava/LocalDateDemo_isLeapYear/?at=master

See also:

  • All JavaEE Videos Playlist
  • All JavaEE Videos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • Kids Tutorial
  • No comments:

    Post a Comment