Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

SQl date conversion to java.util.Date object  RSS feed

 
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
Sheriff
Posts: 37242
519
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
Boost this thread!