between java.time.LocalTime (next day) -


please suggest if there api support determine if time between 2 localtime instances, or suggest different approach.

i have entity:

 class place {    localtime startday;    localtime endday;  } 

which stores working day start , end time, i.e. '9:00' till '17:00', or nightclub '22:00' till "5:00".

i need implement place.isopen() method determines if place open @ given time.

a simple isbefore/isafter not work here, because need determine if end time on next day.

of course, can compare start , end times , make decision, want without additional logic, simple between() call. if localtime not sufficient purpose, please suggest other.

if understand correctly, need make 2 cases depending on whether closing time on same day opening time (9-17) or on next day (22-5).

it be:

public static boolean isopen(localtime start, localtime end, localtime time) {   if (start.isafter(end)) {     return !time.isbefore(start) || !time.isafter(end);   } else {     return !time.isbefore(start) && !time.isafter(end);   } } 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -