Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dates

 
vin Hari
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
please tell me how to compare dates like
12/12/2006 assume as todays date and 10/12/2006 as another date
hoow to compare these dates.
 
Joice Jose
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use java.util.Date class to compare dates. This class provides methods such as compareTo(), after(), before(), etc.
 
Chengwei Lee
Ranch Hand
Posts: 884
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look into the Java API. Take a look at the following classes: Calendar, GregorianCalendar & Date. You need to know that when doing date comparison, its not really just the day component, there's also the time component, if it is to be disregarded, you have to set the time component to be the same.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic