Which is the right way to compare Time in Java?
I mean java.sql.Time.
Or is there a better way we can compare time in Joda Time?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you can use Joda Time do so. Convert all sql types to Joda equivalents at the persistence layer and then work with Joda objects in your business logic. You won’t regret it, believe me.
LocalTime is probably the object you want to use then you can use
compareTo(),isAfter(),isBefore(). Its also really easy to merge this into a full DateTime if necessary.