Java holds two Date classes; one in java.util package and another in java.sql
A java.util.Date
represents date and time of day, a java.sql.Date
only represents a date. The complement of java.sql.Date
is java.sql.Time
, which only represents a time of day.
The java.sql.Date
is a subclass (an extension) of java.util.Date
. So, what changed in java.sql.Date
:
– toString()
generates a different string representation: yyyy-mm-dd
– a static valueOf(String)
methods to create a date from a string with above representation
– the getters and setter for hours, minutes and seconds are deprecated
The java.sql.Date
class is used with JDBC and it was intended to not have a time part, that is, hours, minutes, seconds, and milliseconds should be zero… but this is not enforced by the class.
post a comment