I would like to check if a given DateTime exists between 4:00 - 8:00 or 12:00 am. What would be the right way to do this?
This seems like a trick:
DateTime start = new DateTime().withHourOfDay(4); DateTime end = new DateTime().withHourOfDay(8); Interval interval = new Interval(start, end); if(interval.contains(now)) return true;
Is there a better way?
source share