protected void computeTime()
描述 (Description)
java.util.GregorianCalendar.computeTime()方法将日历字段值转换为时间值(距Epoch的毫秒偏移量)。
声明 (Declaration)
以下是java.util.GregorianCalendar.computeTime()方法的声明
protected void computeTime()
参数 (Parameters)
NA
返回值 (Return Value)
此方法不返回值。
异常 (Exception)
NA
例子 (Example)
以下示例显示了java.util.GregorianCalendar.computeTime()方法的用法。
package com.iowiki;
import java.util.*;
public class GregorianCalendarDemo extends GregorianCalendar {
public static void main(String[] args) {
// create a new calendar
GregorianCalendarDemo cal = new GregorianCalendarDemo();
// print the current date and time
System.out.println("" + cal.getTime());
// set a new year
cal.set(GregorianCalendar.YEAR, 1992);
System.out.println("" + cal.getTime());
// compute time and print the date
cal.computeTime();
System.out.println("" + cal.getTime());
}
}
让我们编译并运行上面的程序,这将产生以下结果 -
Wed Jun 20 17:25:58 EEST 2012
Sat Jun 20 17:25:58 EEST 1992
Sat Jun 20 17:25:58 EEST 1992