Google News
logo
JDBC - Interview Questions
What is the difference between java.util.Date and java.sql.Date?
java.util.Date contains information about the date and time, whereas java.sql.Date contains information about the date, but has no information about the time. If you need to store time information in the database, it is desirable to use the Timestamp or DateTime fields.
 
Java.util.Date is the main universal object. It simply stores the date (as long).
 
java.sql.Date extends java.util.Date and adds the following functionality :
 
1) toString prints the date as “yyyy-mm-dd”, rather than as a specific locale of the string (locale).
 
2) Added the valueOf method to read the “yyyy-mm-dd” format strings and further parse it into the sql.Date object.
Advertisement