This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Java in General and the fly likes Time between two time values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Time between two time values" Watch "Time between two time values" New topic
Author

Time between two time values

Martin Coetzee
Greenhorn

Joined: Dec 02, 2003
Posts: 21
Hi there everyone. Hopefully somebody can help me with this problem. I've got a time value. i.e. 11:25, now I need to check if the time falls in between a range: I.E. 08:00 and 19:00. What's the best way of validating that this time falls in this range? I'm sure I can compare the integer values, but I'm looking for a something in the Calendar API's that can provide me with this kind of functionality.

Thanks
Martin
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14114
    
  16

Calendar (and also Date) has before() and after() methods that you can use to see if a Calendar or Date represents a date and time that is before or after another date and time. See the API documentation for more information.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Time between two time values