Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How do you validate Dates between 2 dates  RSS feed

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
IHow do you validate that date1 > date2 in Java. How do you check for this and for other date validation stuffs. Any help would be really aprreciated.
 
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look at the compareTo() method in Date. Good for making simple comparisons. For some other date validation (e.g. "is it a weekday?") you may want to use a GregorianCalendar, which has many different methods, depending what you need.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!