How to check whether a time is between particular range?

前端 未结 4 1034
温柔的废话
温柔的废话 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 07:12

    Using Date for the current time is fine. There's a few ways you can go about it.

    1. System.currentTimeInMillis()
    
    2. Date today = new Date()
    

提交回复
热议问题