Java Reference
In-Depth Information
* it represents midnight, local time, at the beginning of
the day
* specified by the <code>year</code>, <code>month</code>,
and
* <code>date</code> arguments.
*
* @param year the year minus 1900.
* @param month the month between 0-11.
* @param date the day of the month between 1-31.
* @see java.util.Calendar
* @deprecated As of JDK version 1.1,
* replaced by <code>Calendar.set(year + 1900, month,
date)</code>
*
or
<code>GregorianCalendar(year
+
1900,
month,
date)</code>.
*/
@Deprecated
public Date(int year, int month, int date)
{
this(year, month, date, 0, 0, 0);
}
This example excerpts one of the constructors in Java's
Date
class (located in the
java.util
package). Its Javadoc comment reveals that
Date(int year, int
month, int date)
has been deprecated in favor of using the
set()
method in
the
Calendar
class(alsolocatedinthe
java.util
package).(Iexplore
Date
and
Calendar
in Appendix C.)
Thecompilersuppresseswarningswhenacompilationunit(typicallyaclassorinter-
face)referstoadeprecatedclass,method,orfield.Thisfeatureletsyoumodifylegacy
APIs without generating deprecation warnings, and is demonstrated in
Listing 3-38
.
Listing 3-38.
Referencing a deprecated field from within the same class declaration
class Employee
{
/**
* Employee's name
* @deprecated new version uses firstName and lastName