LocalDate

Description

LocalDate class represents a date without a time or time zone.

LocalDate is used when the time and time zone are related.

LocalDate class contains two constants, MAX and MIN.

MAX and MIN are the maximum and minimum supported LocalDate respectively.

LocalDate.MAX is +999999999-12-31 and LocalDate.MIN is -999999999-01-01.

Example

The following code shows how to create LocalDate objects:


import java.time.LocalDate;
import java.time.Month;
/*from   w w  w  .  jav a 2  s  .  com*/
public class Main {
  public static void main(String[] args) {
    // Get the current local date
    LocalDate localDate1  = LocalDate.now();
    System.out.println(localDate1);
    // Create a  local date
    LocalDate localDate2  = LocalDate.of(2014, Month.JUNE, 21);
    System.out.println(localDate2);
    // 10000  days after the epoch date 1970-01-01
    LocalDate localDate3  = LocalDate.ofEpochDay(10000);
    System.out.println(localDate3);
  }
}

The code above generates the following result.





















Home »
  Java Date Time »
    Tutorial »




Java Date Time Tutorial