目录

protected abstract void computeTime()

描述 (Description)

java.util.Calendar.computeFields()方法用于将fields []中的当前日历字段值转换为毫秒时间值时间。

声明 (Declaration)

以下是java.util.Calendar.computeFields()方法的声明

protected abstract void computeTime()

参数 (Parameters)

NA

返回值 (Return Value)

此方法不返回任何值。

异常 (Exception)

NA

例子 (Example)

以下示例显示了java.util.Calendar.computeTime()方法的用法。

package com.iowiki;
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
↑回到顶部↑
WIKI教程 @2018