Example usage for java.time LocalDate isLeapYear

List of usage examples for java.time LocalDate isLeapYear

Introduction

In this page you can find the example usage for java.time LocalDate isLeapYear.

Prototype

@Override 
public boolean isLeapYear() 

Source Link

Document

Checks if the year is a leap year, according to the ISO proleptic calendar system rules.

Usage

From source file:Main.java

public static void main(String[] argv) {
    LocalDate today = LocalDate.now();
    if (today.isLeapYear()) {
        System.out.println("This year is Leap year");
    } else {/* w  w  w  .ja va  2  s. com*/
        System.out.println("not a Leap year");
    }

    if (today.withYear(2016).isLeapYear()) {
        System.out.println("2016 is Leap year");
    }

}

From source file:Main.java

public static void main(String[] args) {
    LocalDate a = LocalDate.of(2014, 6, 30);

    System.out.println(a.isLeapYear());
}

From source file:Main.java

public static void main(String[] args) {
    LocalDate today = LocalDate.now();

    // Get the Year, check if it's leap year
    System.out.println("Year " + today.getYear() + " is Leap Year? " + today.isLeapYear());

    // Compare two LocalDate for before and after
    System.out.println("Today is before 01/01/2015? " + today.isBefore(LocalDate.of(2015, 1, 1)));

    // Create LocalDateTime from LocalDate
    System.out.println("Current Time=" + today.atTime(LocalTime.now()));

}

From source file:Main.java

public static void main(String[] args) {
    LocalDate date = LocalDate.of(2014, 2, 15); // 2014-02-15
    System.out.println(date.getYear()); // 2014
    System.out.println(date.getDayOfYear()); // 46
    System.out.println(date.lengthOfYear()); // 365
    System.out.println(date.isLeapYear()); // false

    Year year_2014 = Year.of(2014);
    System.out.println(year_2014.isLeap()); // false
}