Java Month get from LocalDate

Description

Java Month get from LocalDate

import java.time.LocalDate;
import java.time.Month;
public class Main {
  public static void main(String[] args) {
    LocalDate ld = LocalDate.of(2020, 5, 2);
    int year = ld.getYear();       // 2020
    Month month = ld.getMonth();   // Month.MAY
    int day = ld.getDayOfMonth();  // 2

    System.out.println(year);/* w  w  w. j ava  2s.c  om*/
    System.out.println(month);
    System.out.println(day);
  }
}



PreviousNext

Related