Java-util-calendar-computetime

提供:Dev Guides
移動先:案内検索

Java.util.Calendar.computeTime()メソッド

説明

  • java.util.Calendar.computeFields()*メソッドを使用して、fields []の現在のカレンダーフィールド値をミリ秒の時刻値timeに変換します。

宣言

以下は* java.util.Calendar.computeFields()*メソッドの宣言です

protected abstract void computeTime()

パラメーター

NA

戻り値

このメソッドは値を返しません。

例外

NA

次の例は、java.util.Calendar.computeTime()メソッドの使用法を示しています。

package com.finddevguides;

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