The from() method of java.time.DayOfWeek is an in-built function in Java which takes a TemporalAccessor defining a date and returns an instance of DayOfWeek corresponding to that date. A TemporalAccessor represents an arbitrary set of date and time information, which this method converts to an instance of DayOfWeek corresponding to that date.
public static DayOfWeek from(TemporalAccessor temporal)
DayOfWeek dayOfWeekObject = DayOfWeek.from(TemporalAccessor temporal)
Parameters: This method takes temporal as parameter where:
Return Value: The function returns an instance of DayOfWeek corresponding to the date specified by temporal
Below programs illustrate the above method:
Day of the Week on 1997-08-15 - FRIDAY
Day of the Week on 2015-07-13 - MONDAY
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.