The moose likes Java in General and the fly likes Compare Hours and Minute in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Compare Hours and Minute in java" Watch "Compare Hours and Minute in java" New topic

Compare Hours and Minute in java

pankaj semwal
Ranch Hand

Joined: Oct 07, 2008
Posts: 303
Hi List,
How can i compare the time in java as my time format is Hours:Minute.
example: i am getting time like this : 1645 and 1500 so how can i compare this time.

Please tell me.

Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

What do you mean by compare? Are you looking for which is earlier/later? If so, the Calendar class has before and after methods. Or do you mean find out how much the time difference is? In which case, these two times are just ultimately a long representing a number of milliseconds. You could subtract one from the other.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
I agree. Here's the link:
subject: Compare Hours and Minute in java
It's not a secret anymore!