Skip to content

Differences between java.util.Date and java.sql.Date in Java

Handling dates is tricky in Java just like handling JSON in Java. This confusion lets developers use libraries like Joda for clean handling of dates. For our references let’s call java.util.date as uDate and java.sql.Date as sDate in this article. The following points try to differentiate between java.util.Date and java.sql.Date in Java.

uDate datatype stores the time information | sDate datatype that doesn’t store time information. Hence, it’s recommended to use over java.util.Date as java.sql.Date doesn’t store second, minute and hour information.

The toString() method of uDate always returns the date in string format monddhh:mm:sszzzyyyy | toString() method of sDate returns the date in yyyy-mm-ddformat.s

Java.util.Date is super-class of java.sql.Date. |  java.sql.DATE inherits all the public method of java.util.DATE like getSeconds(), getMinutes(), getHours() and so on. This override all the time operation from the superclass i.e. java.util.DATE.

1 Comment »

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.