File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Time between two time values

 
Martin Coetzee
Greenhorn
Posts: 21
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic