what is the difference between java.util.Date and java.sql.Date?
In which case do I have to use util.date and sql.date?
why these two things are provided in java?
Printable View
what is the difference between java.util.Date and java.sql.Date?
In which case do I have to use util.date and sql.date?
why these two things are provided in java?
Java.util.Date is a basic, all-purpose Date object. It simply stores a Date (as a long) and allows you to display it.
java.sql.Date extends java.util.Date to add the following functionality:
1) toString now outputs the date as "yyyy-mm-dd" instead of as a Locale specific String
2) add the valueOf method to read a String of "yyyy-mm-dd" format and parse it into a sql.Date object.
The above information was helpful. Can we extract Time information from java.sql.Date api?
Yes, the Java standard Date is really a DateTime. Its poorly named.
And it is far harder to use than it should be. They layered in the Calendar classes in a fairly early version (java 1.2?) which made it less terrible to use if you are using western european GregorianCalendars. But its still far harder to use than it should be.
And there are threading issues with some of the SimpleDateFormat classes.
There is a replacement, JodaTime that is a clean design. It supports many more calendars (hebrew, islamic, etc.) and has a far more obvious API
The whole java.sql.Date vs java.lang.Date thing is another example of hurried design and is a hack.
Hello to all ! Great site. I am new here greetings to all from Poland.
it doesn't store the time , only the date value.
it's different from java.util.date.
(10x to semicolon)