after public boolean after(Date when)测试此日期是否在指定日期之后。 参数: when - 日期。 返回: 当且仅当此 Date 对象表示的瞬间比 when 表示的瞬间晚,才返回 true;否则返回 false。 抛出: NullPointerException - 如果 when 为 null。before public boolean before(Date when)测试此日期是否在指定日期之前。 参数: when - 日期。 返回: 当且仅当此 Date 对象表示的瞬间比 when 表示的瞬间早,才返回 true;否则返回 false。 抛出: NullPointerException - 如果 when 为 null。
Date d1,d2; ...... d1.after(d2); d1.before(d2);
dt1.compareTo(dt2) compareTo public int compareTo(Date anotherDate)比较两个日期的顺序。 指定者: 接口 Comparable<Date> 中的 compareTo 参数: anotherDate - 要比较的 Date。 返回: 如果参数 Date 等于此 Date,则返回值 0;如果此 Date 在 Date 参数之前,则返回小于 0 的值;如果此 Date 在 Date 参数之后,则返回大于 0 的值。 抛出: NullPointerException - 如果 anotherDate 为 null。 从以下版本开始: 1.2
public boolean after(Date when)测试此日期是否在指定日期之后。 参数:
when - 日期。
返回:
当且仅当此 Date 对象表示的瞬间比 when 表示的瞬间晚,才返回 true;否则返回 false。
抛出:
NullPointerException - 如果 when 为 null。before
public boolean before(Date when)测试此日期是否在指定日期之前。 参数:
when - 日期。
返回:
当且仅当此 Date 对象表示的瞬间比 when 表示的瞬间早,才返回 true;否则返回 false。
抛出:
NullPointerException - 如果 when 为 null。
......
d1.after(d2);
d1.before(d2);
compareTo
public int compareTo(Date anotherDate)比较两个日期的顺序。 指定者:
接口 Comparable<Date> 中的 compareTo
参数:
anotherDate - 要比较的 Date。
返回:
如果参数 Date 等于此 Date,则返回值 0;如果此 Date 在 Date 参数之前,则返回小于 0 的值;如果此 Date 在 Date 参数之后,则返回大于 0 的值。
抛出:
NullPointerException - 如果 anotherDate 为 null。
从以下版本开始:
1.2
before()
getTime()
都可以啊
boolean Date.after(Date when)
测试此日期是否在指定日期之后。
boolean Date.before(Date when)
测试此日期是否在指定日期之前。
int Date.compareTo(Date anotherDate)
比较两个日期的顺序。