Formats this month-day using the specified formatter.
package com.logicbig.example.monthday;
import java.time.MonthDay;
import java.time.format.DateTimeFormatter;
public class FormatExample {
public static void main(String... args) {
MonthDay m = MonthDay.of(10, 3);
System.out.println(m);
format(m, "dd/MMM");
format(m, "dd-MMMM");
format(m, "d/M");
}
private static void format(MonthDay m, String pattern) {
DateTimeFormatter f = DateTimeFormatter.ofPattern(pattern);
String s = m.format(f);
System.out.printf("%s > %s%n", pattern, s);
}
}
Output
--10-03
dd/MMM > 03/Oct
dd-MMMM > 03-October
d/M > 3/10