Why so many methods deprecated in java.util.Date.

N

nhsoft.xy

eg.
/**
* Returns the day of the month represented by this <tt>Date</tt>
object.
* The value returned is between <code>1</code> and <code>31</code>

* representing the day of the month that contains or begins with
the
* instant in time represented by this <tt>Date</tt> object, as
* interpreted in the local time zone.
*
* @return the day of the month represented by this date.
* @see java.util.Calendar
* @deprecated As of JDK version 1.1,
* replaced by <code>Calendar.get(Calendar.DAY_OF_MONTH)</code>.
* @deprecated
*/
@Deprecated
public int getDate() {
return normalize().getDayOfMonth();
}

Why, I think Calendar.get(Calendar.DAY_OF_MONTH) is more ugly then
Date.getDate()
 
B

Bjorn Abelli

Why, I think Calendar.get(Calendar.DAY_OF_MONTH) is more ugly
then Date.getDate()

You'll find one explanation in the JDK:

"The class Date represents a specific instant in time,
with millisecond precision.

Prior to JDK 1.1, the class Date had two additional functions.
/.../ Unfortunately, the API for these functions was not amenable
to internationalization. /.../"

http://java.sun.com/j2se/1.5.0/docs/api/java/util/Date.html

So, instead of trying to "fix" the Date-class, they provided the new
Calendar-classes, and deprecated the corresponding methods in Date.

The Date class is now to be considered only as a Holder for that millisecond
in time, which in different TimeZones mean different local times.

As such it's still useful as e.g. the superclass of java.sql.Date,
java.sql.Time, java.sql.Timestamp.


// Bjorn A
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top