LocalDate format(DateTimeFormatter formatter) example
Description
LocalDate format(DateTimeFormatter formatter)
formats this date using the specified formatter. This date will be passed to
the formatter to produce a string.
Syntax
format
has the following syntax.
public String format(DateTimeFormatter formatter)
Example
The following example shows how to use format
.
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
//from www . ja v a 2s . c o m
public class Main {
public static void main(String[] args) {
LocalDate a = LocalDate.of(2014, 6, 30);
String s = a.format(DateTimeFormatter.BASIC_ISO_DATE);
System.out.println(s);
}
}
The code above generates the following result.