目录

protected void computeFields()

描述 (Description)

java.util.GregorianCalendar.computeFields()方法将时间值(从Epoch的毫秒偏移量java.util.GregorianCalendar.computeFields()转换为日历字段值。 时间不会先重新计算; 重新计算时间,然后是字段,调用完整的方法。

声明 (Declaration)

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

protected void computeFields()

参数 (Parameters)

NA

返回值 (Return Value)

此方法不返回值。

异常 (Exception)

NA

例子 (Example)

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

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 fields and print the date
      cal.computeFields();
      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
↑回到顶部↑
WIKI教程 @2018