This article is based on Oracle Java official documentation, after personal practice to organize and accumulate, for reference only.
1 Java.time.Month is an enumeration type, consisting of 12 constants representing January to December
/* =================== Sample Code =================== */Package test;
Import Java.time.Month;
Import Org.junit.Test; public class Datetimetest {@Test public void Test () {System.out.println ("month.january:" + Month.ja
Nuary);
System.out.println ("month.february:" + month.february);
System.out.println ("Month.march:" + month.march);
System.out.println ("Month.april:" + month.april);
System.out.println ("Month.may:" + month.may);
System.out.println ("Month.june:" + month.june);
System.out.println ("month.july:" + month.july);
System.out.println ("Month.august:" + month.august);
System.out.println ("Month.september:" + month.september);
System.out.println ("Month.october:" + month.october);
System.out.println ("Month.november:" + month.november);
System.out.println ("Month.december:" + month.december); }}/* =================== test result =================== * * Month.JANUARY:JANUARY Month.FEBRUARY:FEBRUARY Month.MARCH:MARCH Month.APRIL:APRIL
Month.MAY:MAY Month.JUNE:JUNE Month.JULY:JULY Month.AUGUST:AUGUST Month.SEPTEMBER:SEPTEMBER Month.OCTOBER:OCTOBER Month.NOVEMBER:NOVEMBER Month.DECEMBER:DECEMBER
2 Gets the maximum number of days of the month through the MaxLength () method
/* =================== Sample Code =================== */Package test;
Import Java.time.Month;
Import Org.junit.Test; public class Datetimetest {@Test public void Test () {System.out.println ("January Maximum days:" + Month.JANUARY.ma
Xlength ());
System.out.println ("February Maximum days:" + Month.FEBRUARY.maxLength ());
System.out.println ("March Maximum days:" + Month.MARCH.maxLength ());
System.out.println ("April Maximum days:" + Month.APRIL.maxLength ());
System.out.println ("May Maximum days:" + Month.MAY.maxLength ());
System.out.println ("June Maximum days:" + Month.JUNE.maxLength ());
System.out.println ("July Maximum days:" + Month.JULY.maxLength ());
System.out.println ("August Maximum days:" + Month.AUGUST.maxLength ());
System.out.println ("September Maximum days:" + Month.SEPTEMBER.maxLength ());
System.out.println ("October Maximum days:" + Month.OCTOBER.maxLength ());
System.out.println ("November Maximum days:" + Month.NOVEMBER.maxLength ()); System.out.println ("December Maximum days:" + Month.DECEMBER.maxLeNgth ());
}/* =================== Test results ===================/* January maximum days: 31 February Maximum days: 29 March Maximum days: 31 April Maximum days: 30 May maximum days: 31 June Maximum days: 30 July Maximum days: 31 August Maximum days: 31 September Maximum days: 30 October Maximum days: 31 November Maximum days: 30 December maximum days: 31
3 Customizing string content using the GetDisplayName (TextStyle, Locale) method
/* =================== Sample Code =================== */Package test;
Import Java.time.Month;
Import Java.time.format.TextStyle;
Import Java.util.Locale;
Import Org.junit.Test; public class Datetimetest {@Test the public void Test () {System.out.println (Month.JANUARY.getD
Isplayname (Textstyle.full, Locale.chinese));
System.out.println (Month.JANUARY.getDisplayName (Textstyle.short, Locale.chinese));
System.out.println (Month.JANUARY.getDisplayName (Textstyle.narrow, Locale.chinese));
System.out.println ();
System.out.println (Month.JANUARY.getDisplayName (Textstyle.full, locale.english));
System.out.println (Month.JANUARY.getDisplayName (Textstyle.short, locale.english));
System.out.println (Month.JANUARY.getDisplayName (Textstyle.narrow, locale.english));
System.out.println (); System.out.println (Month.JANUARY.getDisplayName (TextStyle.full, Locale.french));
System.out.println (Month.JANUARY.getDisplayName (Textstyle.short, locale.french));
System.out.println (Month.JANUARY.getDisplayName (Textstyle.narrow, locale.french));
System.out.println ();
System.out.println (Month.JANUARY.getDisplayName (Textstyle.full, Locale.germany));
System.out.println (Month.JANUARY.getDisplayName (Textstyle.short, Locale.germany));
System.out.println (Month.JANUARY.getDisplayName (Textstyle.narrow, Locale.germany));
System.out.println ();
}/* =================== Test Results =================== * January January 1 January janvier Janv. J Januar, J.