See if the current time falls within a specific range of time in the current day in Java

前端 未结 6 892
天命终不由人
天命终不由人 2020-12-10 13:52

I am sure this was done 1000 times in 1000 different places. The question is I want to know if there is a better/standard/faster way to check if current \"time\" is between

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-10 14:39

    As pointed out by Kevin, Fuzzy Lollipop's Regex won't pick up times between 14:00 and 19:00.

    To get match a full 24 hour clock, you can use this:

    if (hhmmss.matches("^([0-1][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$"))
    {
        // Do stuff here
    }
    

提交回复
热议问题