How to check whether a time is between particular range?

前端 未结 4 1069
温柔的废话
温柔的废话 2021-01-23 06:36

I need to check whether current time is between 8 AM and 3 PM or not. If it is between those time range, then I need to return yes otherwise return false.

boolea         


        
4条回答
  •  梦谈多话
    2021-01-23 06:54

    Joda Time is a pretty straightforward library to be used, and if you define the comparison date objects as LocalDate, then you can use the isBefore(), isAfter() boolean methods: https://docs.oracle.com/javase/8/docs/api/java/time/LocalDateTime.html#isBefore-java.time.chrono.ChronoLocalDateTime- Hope it helps!

提交回复
热议问题