I get time from server in format { "from" : "12-00", "to" : "01-00" } Then, I parse it like this
DateTimeFormat.forPattern("HH:mm").parseDateTime(dateString)
Then, I need to check if current time is in this hour range:
Interval(from, to).containsNow()
Interval constructor throws error because second date more than first DateTime object time is 1970-01-01T12:00:00.000Z and 1970-01-01T01:00:00.000Z
How can I check if current hour is in hour range? Is there any hour range in Joda?
Since you are using 24-hour format, you need to use the date as well. You are currently comparing 12:00 of 01-01-1970 (the Unix start Date) with 01:00 of the same day, and 12:00 is after 1:00 and that is an invalid interval.
Change the DateTime pattern to "MM/dd/yyyy HH:mm" or something else that works for you and contains both the date and the time that suits your needs. Then, you can make the check.