check if date() is monday? java

后端 未结 4 491
别跟我提以往
别跟我提以往 2021-02-08 03:34

Is there a way to check if a java Date object is Monday? I see you can with a Calendar object, but date? I\'m also using US-eastern date and time if th

4条回答
  •  北恋
    北恋 (楼主)
    2021-02-08 04:09

    Something like this will work:

    Calendar cal = Calendar.getInstance();
    cal.setTime(theDate);
    boolean monday = cal.get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY;
    

提交回复
热议问题