MonthDay format(DateTimeFormatter formatter)
formats this month-day using the specified formatter.
format
has the following syntax.
public String format(DateTimeFormatter formatter)
The following example shows how to use format
.
import java.time.MonthDay; import java.time.format.DateTimeFormatter; /*from w w w . jav a 2s . 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.