This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SQl date conversion to java.util.Date object

 
Poonam Kadu
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello friends,
How do I convert a date (mm/dd/yyyy)from SQl dbase to java.util.Date or java.sql.Date and then compare it with the current date retrieved through jaav.util.Date ?

cheers,
Poonam
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34094
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Poonam,
You can get the date from the database as a java.sql.Date through rs.getDate() if you just need the date. [You would use rs.getTime() or rs.getTimeStamp() if you needed the time too.]

You can get the current system date as new java.util.Date(). Since java.sql.Date is a subclass of java.util.Date, you can compare the values using date1.compareTo(date2).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic