Date and Time
Date and Time
by
Giridhara R M.E.,M.B.A.,
Assistant Professor,
Dept of CSE,
Sri Eshwar College of Engineering
Example Program :
DayOfWeek dow = DayOfWeek.MONDAY; Output :
Locale locale = Locale.getDefault(); Monday
System.out.println(dow.getDisplayName(TextStyle.FULL, locale)); M
System.out.println(dow.getDisplayName(TextStyle.NARROW, locale)); Mon
System.out.println(dow.getDisplayName(TextStyle.SHORT, locale));
System.out.printf("%d%n", Month.FEBRUARY.maxLength());
Example Program :
Month month = Month.AUGUST; Output:
Locale locale = Locale.getDefault(); August
System.out.println(month.getDisplayName(TextStyle.FULL, locale)); A
System.out.println(month.getDisplayName(TextStyle.NARROW, locale)); Aug
System.out.println(month.getDisplayName(TextStyle.SHORT, locale));
●
The getDayOfWeek method returns the day of the week that a particular
date falls on. the following line of code returns "MONDAY":
DayOfWeek dotw = LocalDate.of(2012, Month.JULY, 9).getDayOfWeek();