java.util.Calendar.computeTime() 方法用于转换当前日历字段值的fields[]到毫秒时间值的时间。
声明
以下是java.util.Calendar.computeTime()方法的声明
protected abstract void computeTime()
参数
-
NA
返回值
此方法不返回任何值。
异常
-
NA
例子
下面的示例演示java.util.Calendar.computeTime()方法的用法。
package com.yiibai; import java.util.*; public class CalendarDemo extends GregorianCalendar { public static void main(String[] args) { // create a new calendar CalendarDemo cal = new CalendarDemo(); // print the current date System.out.println("The current date is : " + cal.getTime()); // clear the calendar cal.clear(); // set a new year and call computeTime() cal.set(GregorianCalendar.YEAR, 1998); cal.computeTime(); // print the current date System.out.println("New date is : " + cal.getTime()); } }
让我们来编译和运行上面的程序,这将产生以下结果:
The current date is : Thu Jun 21 15:35:42 EEST 2012 New date is : Thu Jan 01 00:00:00 EET 1998