In my app I create an object that represents a high school class. This object holds 2 Calendar objects that represents the class\'s start and stop time each day. When a user c
I will here only provide the Joda-Time-related answer you asked for. Joda-Time has the advantage to offer a dedicated type for the clock time, namely LocalTime. The old java.util.Calendar
-stuff does not offer this advantage hence your difficulties.
First you convert an instance of java.util.Date
like follows:
Date time = ...;
DateTime dt = new DateTime(time, DateTimeZone.getDefault());
LocalTime lt = dt.toLocalTime();
Note that the conversion is always timezone dependent. Then you can compare two LocalTime
instances using the inherited methods isAfter(...)
or isBefore(...)
.