java.util.Date exists simply to *store* dates, the calendar class and the dateFormat class exist to *manipulate* dates. java.sql.Date exists because SQL has different conventions for storing a date than the JVM.
The Java API docs for java.util.Date explain the deprecated methods.


"Prior to JDK 1.1, the class |Date| had two additional functions. It allowed the interpretation of dates as year, month, day, hour, minute, and second values. It also allowed the formatting and parsing of date strings. Unfortunately, the API for these functions was not amenable to internationalization. As of JDK 1.1, the |Calendar| class should be used to convert between dates and time fields and the |DateFormat| class should be used to format and parse date strings. The corresponding methods in |Date| are deprecated."

java.sql.Date is simply a java.util.Date object that has its hours, minutes, and seconds values set to zero since SQL DATEs do not have a time component.

In summary,

java.util.Date is the standard java API mechanism for storing a date.
java.sql.Date is a subclass of java.util.Date with a subset of the functionality designed to represent the functionality provided by a SQL DATE.
java.sql.Timestamp is a composite of Date and an extra nanoseccond value designed to represent the functionality provided by a SQL TIMESTAMP.


Gareth

Mark Galbreath wrote:

java.sql.Date is a subclass of java.util.Date (as is java.sql.TimeStamp) and
as far as I can see, is the only reason for the latter's existence.  As
David Flannigan points out in "Java In A Nutshell, 4th Ed" (O'Reilly 2002),
p. 654: "Since Java 1.1 many of the methods in the Date class have been
deprecated in favor of the methods of the Calendar class."  java.sql.Date
exists simply to pass milliseconds through JDBC to and from a database.

Mark





--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to