This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

To check the input date is future date or not  RSS feed

 
Shein Zeya
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm now trying to check an input date is valid or not:that is DOB,
if the date is the future date,it cannot be DOb and so alert that the Date is invalid.
if not....accept it.
So......first..I have to change the incoming date form to my fixed date form.Then compare it.
I know the concept ,but I just want to get tge reference.
Thank you.
Pls help.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use the SimpleDateFormatclass to convert your input date to a Dateobject. Create another Date object tio represent the current time and then use methods in the Date class to compare them.
[ June 05, 2008: Message edited by: Joanne Neal ]
 
Campbell Ritchie
Marshal
Posts: 55715
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Calendar class implements the Comparable<Calendar> interface, so you can compare your date with what the Calendar class API calls "rightNow." If you get a value >0 you are onto a winner!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!