Java LocalDate get year, month, day of month

Description

Java LocalDate get year, month, day of month

import java.time.LocalDate;
import java.time.Month;

public class Main {
  public static void main(String[] args) {
    LocalDate localDate = LocalDate.of(2014, 6, 21);
    int year = localDate.getYear();
    System.out.println(year);//  ww  w  .j a  v  a  2 s. co m
    
    Month month = localDate.getMonth();
    System.out.println(month);

    int day = localDate.getDayOfMonth();
    System.out.println(day);

  }
}



PreviousNext

Related