@@ -18,9 +18,18 @@ public static void main(String[] args) {
1818 int minute = sc .nextInt ();
1919 System .out .print ("Second: " );
2020 int second = sc .nextInt ();
21- GregorianCalendar datetime = new GregorianCalendar (year , month , day , hour , minute , second ); // Get the date and time values based on user entered input
22- LocalDateTime dateandtime = LocalDateTime .of (year , month , day , hour , minute , second ); // Convert datetime GregorianCalendar object to LocalDateTime object named dateandtime without time zone information
23- DateTimeFormatter era1 = DateTimeFormatter .ofPattern ("GGG" ); // Format the date and time values with specified pattern
21+ GregorianCalendar datetime = new GregorianCalendar (year , month , day , hour , minute , second ); // Get the date and
22+ // time values based
23+ // on user entered
24+ // input
25+ LocalDateTime dateandtime = LocalDateTime .of (year , month , day , hour , minute , second ); // Convert datetime
26+ // GregorianCalendar
27+ // object to LocalDateTime
28+ // object named
29+ // dateandtime without
30+ // time zone information
31+ DateTimeFormatter era1 = DateTimeFormatter .ofPattern ("GGG" ); // Format the date and time values with specified
32+ // pattern
2433 DateTimeFormatter era2 = DateTimeFormatter .ofPattern ("GGGG" );
2534 DateTimeFormatter era3 = DateTimeFormatter .ofPattern ("GGGGG" );
2635 DateTimeFormatter year1 = DateTimeFormatter .ofPattern ("uu" );
@@ -66,19 +75,27 @@ public static void main(String[] args) {
6675 DateTimeFormatter timezoneoffsetz = DateTimeFormatter .ofPattern ("XXXXX" );
6776 DateTimeFormatter timezoneoffsetx = DateTimeFormatter .ofPattern ("xxxxx" );
6877 DateTimeFormatter timezoneoffset2 = DateTimeFormatter .ofPattern ("ZZZZZ" );
69- System .out .println ("Era: " + era1 .format (dateandtime ) + " (" + era2 .format (dateandtime ) + ")" + " (" + era3 .format (dateandtime ) + ")" ); // Print the date and time values with formatted date and time pattern
78+ System .out .println ("Era: " + era1 .format (dateandtime ) + " (" + era2 .format (dateandtime ) + ")" + " ("
79+ + era3 .format (dateandtime ) + ")" ); // Print the date and time values with formatted date and time
80+ // pattern
7081
7182 System .out .println ("Year: " + year1 .format (dateandtime ) + " (" + year2 .format (dateandtime ) + ")" );
7283 System .out .println ("Era Year: " + yearera .format (dateandtime ) + " (" + yearera2 .format (dateandtime ) + ")" );
7384 System .out .println ("Day of Year: " + dayofyear .format (dateandtime ));
74- System .out .println ("Month of Year: " + monthofyear .format (dateandtime ) + " (" + monthofyear2 .format (dateandtime ) + ")" + " (" + monthofyear3 .format (dateandtime ) + ")" + " (" + monthofyear4 .format (dateandtime ) + ")" );
85+ System .out .println ("Month of Year: " + monthofyear .format (dateandtime ) + " (" + monthofyear2 .format (dateandtime )
86+ + ")" + " (" + monthofyear3 .format (dateandtime ) + ")" + " (" + monthofyear4 .format (dateandtime ) + ")" );
7587 System .out .println ("Day of Month: " + dayofmonth .format (dateandtime ));
76- System .out .println ("Quarter: " + quarter .format (dateandtime ) + " (" + quarter2 .format (dateandtime ) + ")" + " (" + quarter3 .format (dateandtime ) + ")" );
77- System .out .println ("ISO Week-based Year: " + yearweek .format (dateandtime ) + " (" + yearweek2 .format (dateandtime ) + ")" );
88+ System .out .println ("Quarter: " + quarter .format (dateandtime ) + " (" + quarter2 .format (dateandtime ) + ")" + " ("
89+ + quarter3 .format (dateandtime ) + ")" );
90+ System .out .println (
91+ "ISO Week-based Year: " + yearweek .format (dateandtime ) + " (" + yearweek2 .format (dateandtime ) + ")" );
7892 System .out .println ("Week of Year: " + weekyear .format (dateandtime ));
7993 System .out .println ("Week of Month: " + weekofmonth .format (dateandtime ));
80- System .out .println ("Day of Week: " + dayofweek .format (dateandtime ) + " (" + dayofweek2 .format (dateandtime ) + ")" + " (" + dayofweek3 .format (dateandtime ) + ")" );
81- System .out .println ("Local Day of Week: " + localdayofweek .format (dateandtime ) + " (" + localdayofweek2 .format (dateandtime ) + ")" + " (" + localdayofweek3 .format (dateandtime ) + ")" + " (" + localdayofweek4 .format (dateandtime ) + ")" );
94+ System .out .println ("Day of Week: " + dayofweek .format (dateandtime ) + " (" + dayofweek2 .format (dateandtime ) + ")"
95+ + " (" + dayofweek3 .format (dateandtime ) + ")" );
96+ System .out .println ("Local Day of Week: " + localdayofweek .format (dateandtime ) + " ("
97+ + localdayofweek2 .format (dateandtime ) + ")" + " (" + localdayofweek3 .format (dateandtime ) + ")" + " ("
98+ + localdayofweek4 .format (dateandtime ) + ")" );
8299 System .out .println ("Local Week of Month: " + localweekofmonth .format (dateandtime ));
83100 System .out .println ("AM/PM: " + ampm .format (dateandtime ));
84101 System .out .println ("12 Hour Format " + hour12 .format (dateandtime ));
@@ -91,7 +108,10 @@ public static void main(String[] args) {
91108 System .out .println ("Millisecond of Day: " + milliofday .format (dateandtime ));
92109 System .out .println ("Nanosecond: " + nanoofsecond .format (dateandtime ));
93110 System .out .println ("Nanosecond of Day: " + nanoofday .format (dateandtime ));
94- LocalDateTime dateandtimenow = LocalDateTime .of (year , month , day , hour , minute , second ); // Get the current date and time based on local computer date and time
111+ LocalDateTime dateandtimenow = LocalDateTime .of (year , month , day , hour , minute , second ); // Get the current date
112+ // and time based on
113+ // local computer date
114+ // and time
95115 DateTimeFormatter nowera1 = DateTimeFormatter .ofPattern ("GGG" ); // Format the current local date and time values
96116 DateTimeFormatter nowera2 = DateTimeFormatter .ofPattern ("GGGG" );
97117 DateTimeFormatter nowera3 = DateTimeFormatter .ofPattern ("GGGGG" );
@@ -138,18 +158,29 @@ public static void main(String[] args) {
138158 DateTimeFormatter nowtimezoneoffsetz = DateTimeFormatter .ofPattern ("XXXXX" );
139159 DateTimeFormatter nowtimezoneoffsetx = DateTimeFormatter .ofPattern ("xxxxx" );
140160 DateTimeFormatter nowtimezoneoffset2 = DateTimeFormatter .ofPattern ("ZZZZZ" );
141- System .out .println ("Current Era: " + nowera1 .format (dateandtimenow ) + " (" + nowera2 .format (dateandtimenow ) + ")" + " (" + nowera3 .format (dateandtimenow ) + ")" ); // Print the formatted date and time values in current local date and time
142- System .out .println ("Current Year: " + nowyear1 .format (dateandtimenow ) + " (" + nowyear2 .format (dateandtimenow ) + ")" );
143- System .out .println ("Current Era Year: " + nowyearera .format (dateandtimenow ) + " (" + nowyearera2 .format (dateandtimenow ) + ")" );
161+ System .out .println ("Current Era: " + nowera1 .format (dateandtimenow ) + " (" + nowera2 .format (dateandtimenow )
162+ + ")" + " (" + nowera3 .format (dateandtimenow ) + ")" ); // Print the formatted date and time values in
163+ // current local date and time
164+ System .out .println (
165+ "Current Year: " + nowyear1 .format (dateandtimenow ) + " (" + nowyear2 .format (dateandtimenow ) + ")" );
166+ System .out .println ("Current Era Year: " + nowyearera .format (dateandtimenow ) + " ("
167+ + nowyearera2 .format (dateandtimenow ) + ")" );
144168 System .out .println ("Current Day of Year: " + nowdayofyear .format (dateandtimenow ));
145- System .out .println ("Month of Year: " + nowmonthofyear .format (dateandtimenow ) + " (" + nowmonthofyear2 .format (dateandtimenow ) + ")" + " (" + nowmonthofyear3 .format (dateandtimenow ) + ")" + " (" + nowmonthofyear4 .format (dateandtimenow ) + ")" );
169+ System .out .println ("Month of Year: " + nowmonthofyear .format (dateandtimenow ) + " ("
170+ + nowmonthofyear2 .format (dateandtimenow ) + ")" + " (" + nowmonthofyear3 .format (dateandtimenow ) + ")"
171+ + " (" + nowmonthofyear4 .format (dateandtimenow ) + ")" );
146172 System .out .println ("Current Day of Month: " + nowdayofmonth .format (dateandtimenow ));
147- System .out .println ("Current Quarter: " + nowquarter .format (dateandtimenow ) + " (" + nowquarter2 .format (dateandtimenow ) + ")" + " (" + nowquarter3 .format (dateandtimenow ) + ")" );
148- System .out .println ("ISO Week-based Year: " + nowyearweek .format (dateandtimenow ) + " (" + nowyearweek2 .format (dateandtimenow ) + ")" );
173+ System .out .println ("Current Quarter: " + nowquarter .format (dateandtimenow ) + " ("
174+ + nowquarter2 .format (dateandtimenow ) + ")" + " (" + nowquarter3 .format (dateandtimenow ) + ")" );
175+ System .out .println ("ISO Week-based Year: " + nowyearweek .format (dateandtimenow ) + " ("
176+ + nowyearweek2 .format (dateandtimenow ) + ")" );
149177 System .out .println ("Current Week of Year: " + nowweekyear .format (dateandtimenow ));
150178 System .out .println ("Current Week of Month: " + nowweekofmonth .format (dateandtimenow ));
151- System .out .println ("Current Day of Week: " + nowdayofweek .format (dateandtimenow ) + " (" + nowdayofweek2 .format (dateandtimenow ) + ")" + " (" + nowdayofweek3 .format (dateandtimenow ) + ")" );
152- System .out .println ("Current Local Day of Week: " + nowlocaldayofweek .format (dateandtimenow ) + " (" + nowlocaldayofweek2 .format (dateandtimenow ) + ")" + " (" + nowlocaldayofweek3 .format (dateandtimenow ) + ")" + " (" + nowlocaldayofweek4 .format (dateandtimenow ) + ")" );
179+ System .out .println ("Current Day of Week: " + nowdayofweek .format (dateandtimenow ) + " ("
180+ + nowdayofweek2 .format (dateandtimenow ) + ")" + " (" + nowdayofweek3 .format (dateandtimenow ) + ")" );
181+ System .out .println ("Current Local Day of Week: " + nowlocaldayofweek .format (dateandtimenow ) + " ("
182+ + nowlocaldayofweek2 .format (dateandtimenow ) + ")" + " (" + nowlocaldayofweek3 .format (dateandtimenow )
183+ + ")" + " (" + nowlocaldayofweek4 .format (dateandtimenow ) + ")" );
153184 System .out .println ("Current Local Week of Month: " + nowlocalweekofmonth .format (dateandtimenow ));
154185 System .out .println ("Current AM/PM: " + nowampm .format (dateandtimenow ));
155186 System .out .println ("Current 12 Hour Format " + nowhour12 .format (dateandtimenow ));
0 commit comments