The format() method of LocalDate class in Java method formats this date using the specified formatter.
Syntax:
public String format(DateTimeFormatter formatter)
Parameter: This method accepts a parameter
obj which specifies the formatter to be used and it is not null.
Exceptions: The function throws only
DateTimeException which occurs during an error in printing.
Return Value: It returns the formatted date string and not null.
Below programs illustrate the
format() method of LocalDate in Java:
Program 1:
Output:
2018-11-01
01/11/2018
Program 2: To illustrate the exception.