I would like to check if the current time is in a defined frame. I tried the following:
if (LocalTime.now().isBefore(config.getEnd()) && LocalTime.now().isAfter(config.getStart())) {
...
}
config.getEnd()
and config.getStart()
return LocalTime
s in the format "HH:mm:ss".
This works as long as the starttime is before the endtime. But if this program should execute in the middle of the night between 23:00:00 and 02:00:00 then of course it doesn't. With the old java.util.date I would deduct 1 day from the starttime but I have no days here.
Does anyone know an elegant solution to this?