How to determine day of week by passing specific date?

前端 未结 25 2105
夕颜
夕颜 2020-11-22 05:12

For Example I have the date: \"23/2/2010\" (23th Feb 2010). I want to pass it to a function which would return the day of week. How can I do this?

I

25条回答
  •  清歌不尽
    2020-11-22 05:45

    LocalDate date=LocalDate.now();
    
    System.out.println(date.getDayOfWeek());//prints THURSDAY
    System.out.println(date.getDayOfWeek().getDisplayName(TextStyle.SHORT, Locale.US) );  //prints Thu   
    java.time.DayOfWeek is a enum which returns the singleton instance for the day-of-week of the weekday of the date.
    

提交回复
热议问题