Date and Time

Localdate of method in java

This returns a LocalDate with the specified year, month and day-of-month, You can use this method if your application get DOB or any date from user in int format.

LocalDate.of contains two overloaded method

public static LocalDate of(int year, int month, int dayOfMonth)

Should pass year, month and day in int format.

public static LocalDate of(int year, Month month, int dayOfMonth)

Should pass a month in Enum Format

Example

package com.candidjava; 

import java.time.LocalDate;

public class LocalDateTest 
{
 public static void main(String[] args) 
 {
 
 LocalDate localDate=LocalDate.of(2020, 11, 25); // yyyy, mm, dd 
 System.out.println("Local date using of() "+localDate);
 
 LocalDate localDate1=LocalDate.of(2020, Month.NOVEMBER, 25); // yyyy, mm, dd
 System.out.println("Local date using of() "+localDate1);
 
 }
}

Output:

Local date using of() 2020-11-25
Local date using of() 2020-11-25