MonthDay format(DateTimeFormatter formatter) example
Description
MonthDay format(DateTimeFormatter formatter)
formats this month-day using the specified formatter.
Syntax
format
has the following syntax.
public String format(DateTimeFormatter formatter)
Example
The following example shows how to use format
.
import java.time.MonthDay;
import java.time.format.DateTimeFormatter;
//w ww.ja va2s . c o m
public class Main {
public static void main(String[] args) {
MonthDay m = MonthDay.now();
String n = m.format(DateTimeFormatter.ofPattern("M"));
System.out.println(n);
}
}
The code above generates the following result.