从类说明中截取了一小段进行了翻译解说明Date类,我觉得对Date有一个初步对象(JDK1.7):
Date类代表一个毫秒值精度的时间。在JDK1.1之前,Date类有两个额外的功能。第一个是允许将时间解释为年、月、日、小时、分钟、秒。另一个就是能格式化和装换时间字符串。不幸的是,在国际化的过程这些功表现并不好。所以在1.1版本中,Calendar类被用来在时间、时间属性与DateFormat类(用作格式和时间字符串转换)之间的转换Date类中的相应方法都被遗弃了。
从类说明中我们也看到了Date类中有很多的方法都被遗弃了,所以对于遗弃的方法这里也不会太关注了,主要关注在目前还能使用的方法,遗弃的方法都会被建议使用Calendar、GregorianCalendar类、DateFormat类的相应方法。Date基本保留成为一个表征时间的功能,对于时间的计算基本都是有Calendar类或相关的类完成。Date中最关键的就是这个毫秒值,很多的方法都是来自于这个。
```
/**
* Date类代表一个毫秒值精度的时间
* <p>
* 在JDK1.1之前,Date类有两个额外的功能。第一个是允许将时间解释为年、月、日、小时、分钟、秒。
* 另一个就是能格式化和装换时间字符串。不幸的是,在国际化的过程这些功表现并不好。
* 所以在1.1版本中,Calendar类被用来在时间、时间属性与DateFormat类(用作格式和时间支付串转换)之间的转换
* Date类中的相应方法都被遗弃了。
*介绍了闰秒和其它想关知识,并不关心
*
* @author James Gosling
* @author Arthur van Hoff
* @author Alan Liu
* @see java.text.DateFormat
* @see java.util.Calendar
* @see java.util.TimeZone
* @since JDK1.0
*/
public class Date
implements java.io.Serializable, Cloneable, Comparable<Date>
{
private static final BaseCalendar gcal =
CalendarSystem.getGregorianCalendar();
private static BaseCalendar jcal;
private transient long fastTime;
/*
* If cdate is null, then fastTime indicates the time in millis.
* If cdate.isNormalized() is true, then fastTime and cdate are in
* synch. Otherwise, fastTime is ignored, and cdate indicates the
* time.
*/
private transient BaseCalendar.Date cdate;
// Initialized just before the value is used. See parse().
private static int defaultCenturyStart;
private static final long serialVersionUID = 7523967970034938905L;
/**
* 初始化一个Date对象并初始化,用系统毫秒值来初始化
Date类代表一个毫秒值精度的时间。在JDK1.1之前,Date类有两个额外的功能。第一个是允许将时间解释为年、月、日、小时、分钟、秒。另一个就是能格式化和装换时间字符串。不幸的是,在国际化的过程这些功表现并不好。所以在1.1版本中,Calendar类被用来在时间、时间属性与DateFormat类(用作格式和时间字符串转换)之间的转换Date类中的相应方法都被遗弃了。
从类说明中我们也看到了Date类中有很多的方法都被遗弃了,所以对于遗弃的方法这里也不会太关注了,主要关注在目前还能使用的方法,遗弃的方法都会被建议使用Calendar、GregorianCalendar类、DateFormat类的相应方法。Date基本保留成为一个表征时间的功能,对于时间的计算基本都是有Calendar类或相关的类完成。Date中最关键的就是这个毫秒值,很多的方法都是来自于这个。
```
/**
* Date类代表一个毫秒值精度的时间
* <p>
* 在JDK1.1之前,Date类有两个额外的功能。第一个是允许将时间解释为年、月、日、小时、分钟、秒。
* 另一个就是能格式化和装换时间字符串。不幸的是,在国际化的过程这些功表现并不好。
* 所以在1.1版本中,Calendar类被用来在时间、时间属性与DateFormat类(用作格式和时间支付串转换)之间的转换
* Date类中的相应方法都被遗弃了。
*介绍了闰秒和其它想关知识,并不关心
*
* @author James Gosling
* @author Arthur van Hoff
* @author Alan Liu
* @see java.text.DateFormat
* @see java.util.Calendar
* @see java.util.TimeZone
* @since JDK1.0
*/
public class Date
implements java.io.Serializable, Cloneable, Comparable<Date>
{
private static final BaseCalendar gcal =
CalendarSystem.getGregorianCalendar();
private static BaseCalendar jcal;
private transient long fastTime;
/*
* If cdate is null, then fastTime indicates the time in millis.
* If cdate.isNormalized() is true, then fastTime and cdate are in
* synch. Otherwise, fastTime is ignored, and cdate indicates the
* time.
*/
private transient BaseCalendar.Date cdate;
// Initialized just before the value is used. See parse().
private static int defaultCenturyStart;
private static final long serialVersionUID = 7523967970034938905L;
/**
* 初始化一个Date对象并初始化,用系统毫秒值来初始化