aspose file tools
The moose likes JDBC and Relational Databases and the fly likes Date Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Barcodes with iOS this week in the iOS forum
or Core Java for the Impatient in the Java 8 forum!

JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Date" Watch "Date" New topic
Author

Date

francis varkey
Ranch Hand

Joined: Sep 13, 2005
Posts: 169
Respected Sirs,

What is the correct way for inserting date values in database using java ?. What is the difference between java.util.Date and java.sql.Date?.


Regards,
Francis
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081

Originally posted by francis varkey:
What is the correct way for inserting date values in database using java ?.


If you have a java.util.Date date and you want to save it in database with time then below is the correct way

TimeStamp timestamp = new TimeStamp(date.getTime());
statement.setTimeStamp(timestamp );





What is the difference between java.util.Date and java.sql.Date?.




sql.Date extend java.util.Date, it is the thin wrappers around a numeric value representing a point in time. The SQl Date class ignore the information regarding the time of day .

Shailesh


Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
 
wood burning stoves
 
subject: Date