How to check if time in day is between two times?

前端 未结 5 734
说谎
说谎 2021-01-27 16:24

In my app I create an object that represents a high school class. This object holds 2 Calendar objects that represents the class\'s start and stop time each day. When a user c

5条回答
  •  伪装坚强ぢ
    2021-01-27 16:52

        try {
            Date date1 = sdf.parse(given time);
            Date date2 = sdf.parse("08:00 AM");
            Date date3 = sdf.parse("06:00 PM");
    
            if((date1.after(date2))&&(date1.before(date3))||date1.equals(date2) ||date1.equals(date3) ) {
    
            } 
        } catch (ParseException e){
            e.printStackTrace();
        }
    

提交回复
热议问题