org.apache.commons.lang.time
クラス DateUtils

java.lang.Object
  拡張org.apache.commons.lang.time.DateUtils

public class DateUtils
extends Object

Calendar オブジェクトと Date オブジェクトを使用する際のユーティリティの集まりです。

A suite of utilities surrounding the use of the {@link java.util.Calendar} and {@link java.util.Date} object.

導入されたバージョン:
2.0
バージョン:
$Id: DateUtils.java,v 1.1.1.1 2004/02/13 10:02:05 hioki Exp $
作成者:
Serge Knystautas, Stephen Colebourne, Janek Bogucki, Gary Gregory
翻訳者:
日置 聡
翻訳状況:
初稿(校正者募集中)
翻訳更新日:
2003/09/21

フィールドの概要
static int MILLIS_IN_DAY
          日の基準となるミリセカンドの数値です。
static int MILLIS_IN_HOUR
          時間の基準となるミリセカンドの数値です。
static int MILLIS_IN_MINUTE
          分の基準となるミリセカンドの数値です。
static int MILLIS_IN_SECOND
          秒の基準となるミリセカンドの数値です。
static int RANGE_MONTH_MONDAY
          週の並びが月曜日から始まる月の並びです。
static int RANGE_MONTH_SUNDAY
          週の並びが日曜日から始まる月の並びです。
static int RANGE_WEEK_CENTER
          日付を中心として基準にした週の並びです。
static int RANGE_WEEK_MONDAY
          月曜日から始まる週の並びです。
static int RANGE_WEEK_RELATIVE
          日付を先頭として基準にした週の並びです。
static int RANGE_WEEK_SUNDAY
          日曜日から始まる週の並びです。
static int SEMI_MONTH
          月の前半か後半かを表現する、月の半分です。
static TimeZone UTC_TIME_ZONE
          (GMT から参照される)UTC タイムゾーンです。
 
コンストラクタの概要
DateUtils()
          DateUtils のインスタンスは一般的なプログラムからは生成すべきではありません。
 
メソッドの概要
static Iterator iterator(Calendar focus, int rangeStyle)
          焦点となる日付と範囲のスタイルから、日付の範囲を表現する Iterator を生成します。
static Iterator iterator(Date focus, int rangeStyle)
          焦点となる日付と範囲のスタイルから、日付の範囲を表現する Iterator を生成します。
static Iterator iterator(Object focus, int rangeStyle)
          焦点となる日付と範囲のスタイルから、日付の範囲を表現する Iterator を生成します。
static Calendar round(Calendar date, int field)
          field で指定された単位で日時を四捨五入します。
static Date round(Date date, int field)
          field で指定された単位で日時を四捨五入します。
static Date round(Object date, int field)
          field で指定された単位で日時を四捨五入します。
static Calendar truncate(Calendar date, int field)
          field で指定された単位で日時を切り捨てます。
static Date truncate(Date date, int field)
          field で指定された単位で日時を切り捨てます。
static Date truncate(Object date, int field)
          field で指定された単位で日時を切り捨てます。
 
クラス java.lang.Object から継承したメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

フィールドの詳細

UTC_TIME_ZONE

public static final TimeZone UTC_TIME_ZONE
(GMT から参照される)UTC タイムゾーンです。
The UTC time zone (often referred to as GMT).


MILLIS_IN_SECOND

public static final int MILLIS_IN_SECOND
秒の基準となるミリセカンドの数値です。
Number of milliseconds in a standard second.

関連項目:
定数フィールド値

MILLIS_IN_MINUTE

public static final int MILLIS_IN_MINUTE
分の基準となるミリセカンドの数値です。
Number of milliseconds in a standard minute.

関連項目:
定数フィールド値

MILLIS_IN_HOUR

public static final int MILLIS_IN_HOUR
時間の基準となるミリセカンドの数値です。
Number of milliseconds in a standard hour.

関連項目:
定数フィールド値

MILLIS_IN_DAY

public static final int MILLIS_IN_DAY
日の基準となるミリセカンドの数値です。
Number of milliseconds in a standard day.

関連項目:
定数フィールド値

SEMI_MONTH

public static final int SEMI_MONTH
月の前半か後半かを表現する、月の半分です。
This is half a month, so this represents whether a date is in the top or bottom half of the month.

関連項目:
定数フィールド値

RANGE_WEEK_SUNDAY

public static final int RANGE_WEEK_SUNDAY
日曜日から始まる週の並びです。
A week range, starting on Sunday.

関連項目:
定数フィールド値

RANGE_WEEK_MONDAY

public static final int RANGE_WEEK_MONDAY
月曜日から始まる週の並びです。
A week range, starting on Monday.

関連項目:
定数フィールド値

RANGE_WEEK_RELATIVE

public static final int RANGE_WEEK_RELATIVE
日付を先頭として基準にした週の並びです。
A week range, starting on the day focused.

関連項目:
定数フィールド値

RANGE_WEEK_CENTER

public static final int RANGE_WEEK_CENTER
日付を中心として基準にした週の並びです。
A week range, centered around the day focused.

関連項目:
定数フィールド値

RANGE_MONTH_SUNDAY

public static final int RANGE_MONTH_SUNDAY
週の並びが日曜日から始まる月の並びです。
A month range, the week starting on Sunday.

関連項目:
定数フィールド値

RANGE_MONTH_MONDAY

public static final int RANGE_MONTH_MONDAY
週の並びが月曜日から始まる月の並びです。
A month range, the week starting on Monday.

関連項目:
定数フィールド値
コンストラクタの詳細

DateUtils

public DateUtils()

DateUtils のインスタンスは一般的なプログラムからは生成すべきではありません。 代わりに DateUtils.parse(str); というように使用すべきです。

DateUtils instances should NOT be constructed in standard programming. Instead, the class should be used as DateUtils.parse(str);.

このコンストラクタは、処理のために JavaBean インスタンスを必要とするツールのために public になっています。

This constructor is public to permit tools that require a JavaBean instance to operate.

メソッドの詳細

round

public static Date round(Date date,
                         int field)

field で指定された単位で日時を四捨五入します。

Round this date, leaving the field specified as the most significant field.

例えば "28 Mar 2002 13:45:01.231" の日時に対して HOUR を指定して処理を行った場合には "28 Mar 2002 14:00:00.000" が返されます。 また、 MONTH が指定された場合には "1 April 2002 0:00:00.000" が返されます。

For example, if you had the datetime of 28 Mar 2002 13:45:01.231, if this was passed with HOUR, it would return 28 Mar 2002 14:00:00.000. If this was passed with MONTH, it would return 1 April 2002 0:00:00.000.

パラメータ:
date - 処理の対象となる日付
the date to work with
field - Calendar のフィールドの値、または SEMI_MONTH
the field from Calendar or SEMI_MONTH
戻り値:
四捨五入が行われた日付
the rounded date
例外:
IllegalArgumentException - date が null の場合
if the date is null

round

public static Calendar round(Calendar date,
                             int field)

field で指定された単位で日時を四捨五入します。

Round this date, leaving the field specified as the most significant field.

例えば "28 Mar 2002 13:45:01.231" の日時に対して HOUR を指定して処理を行った場合には "28 Mar 2002 14:00:00.000" が返されます。 また、 MONTH が指定された場合には "1 April 2002 0:00:00.000" が返されます。

For example, if you had the datetime of 28 Mar 2002 13:45:01.231, if this was passed with HOUR, it would return 28 Mar 2002 14:00:00.000. If this was passed with MONTH, it would return 1 April 2002 0:00:00.000.

パラメータ:
date - 処理の対象となる日付
the date to work with
field - Calendar のフィールドの値、または SEMI_MONTH
the field from Calendar or SEMI_MONTH
戻り値:
四捨五入が行われた日付(異なるオブジェクト)
the rounded date (a different object)
例外:
IllegalArgumentException - date が null の場合
if the date is null

round

public static Date round(Object date,
                         int field)

field で指定された単位で日時を四捨五入します。

Round this date, leaving the field specified as the most significant field.

例えば "28 Mar 2002 13:45:01.231" の日時に対して HOUR を指定して処理を行った場合には "28 Mar 2002 14:00:00.000" が返されます。 また、 MONTH が指定された場合には "1 April 2002 0:00:00.000" が返されます。

For example, if you had the datetime of 28 Mar 2002 13:45:01.231, if this was passed with HOUR, it would return 28 Mar 2002 14:00:00.000. If this was passed with MONTH, it would return 1 April 2002 0:00:00.000.

パラメータ:
date - Date または Calendar で指定された処理の対象となる日付
the date to work with, either Date or Calendar
field - Calendar のフィールドの値、または SEMI_MONTH
the field from Calendar or SEMI_MONTH
戻り値:
四捨五入が行われた日付
the rounded date
例外:
IllegalArgumentException - date が null の場合
if the date is null
ClassCastException - object の型が Date または Calendar 以外だった場合
if the object type is not a Date or Calendar

truncate

public static Date truncate(Date date,
                            int field)

field で指定された単位で日時を切り捨てます。

Truncate this date, leaving the field specified as the most significant field.

例えば "28 Mar 2002 13:45:01.231" の日時に対して HOUR を指定して処理を行った場合には "28 Mar 2002 13:00:00.000" が返されます。 また、 MONTH が指定された場合には "1 Mar 2002 0:00:00.00" が返されます。

For example, if you had the datetime of 28 Mar 2002 13:45:01.231, if you passed with HOUR, it would return 28 Mar 2002 13:00:00.000. If this was passed with MONTH, it would return 1 Mar 2002 0:00:00.000.

パラメータ:
date - 処理の対象となる日付
the date to work with
field - Calendar のフィールドの値、または SEMI_MONTH
the field from Calendar or SEMI_MONTH
戻り値:
切り捨てが行われた日付
the rounded date
例外:
IllegalArgumentException - date が null の場合
if the date is null

truncate

public static Calendar truncate(Calendar date,
                                int field)

field で指定された単位で日時を切り捨てます。

Truncate this date, leaving the field specified as the most significant field.

例えば "28 Mar 2002 13:45:01.231" の日時に対して HOUR を指定して処理を行った場合には "28 Mar 2002 13:00:00.000" が返されます。 また、 MONTH が指定された場合には "1 Mar 2002 0:00:00.00" が返されます。

For example, if you had the datetime of 28 Mar 2002 13:45:01.231, if you passed with HOUR, it would return 28 Mar 2002 13:00:00.000. If this was passed with MONTH, it would return 1 Mar 2002 0:00:00.000.

パラメータ:
date - 処理の対象となる日付
the date to work with
field - Calendar のフィールドの値、または SEMI_MONTH
the field from Calendar or SEMI_MONTH
戻り値:
切り捨てが行われた日付(異なるオブジェクト)
the rounded date (a different object)
例外:
IllegalArgumentException - date が null の場合
if the date is null

truncate

public static Date truncate(Object date,
                            int field)

field で指定された単位で日時を切り捨てます。

Truncate this date, leaving the field specified as the most significant field.

例えば "28 Mar 2002 13:45:01.231" の日時に対して HOUR を指定して処理を行った場合には "28 Mar 2002 13:00:00.000" が返されます。 また、 MONTH が指定された場合には "1 Mar 2002 0:00:00.00" が返されます。

For example, if you had the datetime of 28 Mar 2002 13:45:01.231, if you passed with HOUR, it would return 28 Mar 2002 13:00:00.000. If this was passed with MONTH, it would return 1 Mar 2002 0:00:00.000.

パラメータ:
date - Date または Calendar で指定された処理の対象となる日付
the date to work with, either Date or Calendar
field - Calendar のフィールドの値、または SEMI_MONTH
the field from Calendar or SEMI_MONTH
戻り値:
切り捨てが行われた日付
the rounded date
例外:
IllegalArgumentException - date が null の場合
if the date is null
ClassCastException - object の型が Date または Calendar 以外だった場合
if the object type is not a Date or Calendar

iterator

public static Iterator iterator(Date focus,
                                int rangeStyle)

焦点となる日付と範囲のスタイルから、日付の範囲を表現する Iterator を生成します。

This constructs an Iterator that will start and stop over a date range based on the focused date and the range style.

例えば、"Thursday, July 4, 2002" と RANGE_MONTH_SUNDAY を指定した場合、"Sunday, June 30,2002" で始まり、"Saturday, August 3, 2002" で終わる Iterator を返します。

For instance, passing Thursday, July 4, 2002 and a RANGE_MONTH_SUNDAY will return an Iterator that starts with Sunday, June 30, 2002 and ends with Saturday, August 3, 2002.

パラメータ:
focus - 処理の対象となる日付
the date to work with
rangeStyle - スタイルを示す定数、iterator(Calendar, int) メソッドで示されるリスト内のどれかである必要があります。
the style constant to use. Must be one of the range styles listed for the {@link #iterator(Calendar, int)} method.
戻り値:
日付のイテレータ
the date iterator
例外:
IllegalArgumentException - date が null または rangeStyle の指定が不正な場合
if the date is null or if the rangeStyle is not

iterator

public static Iterator iterator(Calendar focus,
                                int rangeStyle)

焦点となる日付と範囲のスタイルから、日付の範囲を表現する Iterator を生成します。

This constructs an Iterator that will start and stop over a date range based on the focused date and the range style.

例えば、"Thursday, July 4, 2002" と RANGE_MONTH_SUNDAY を指定した場合、"Sunday, June 30,2002" で始まり、"Saturday, August 3, 2002" で終わる Iterator を返します。

For instance, passing Thursday, July 4, 2002 and a RANGE_MONTH_SUNDAY will return an Iterator that starts with Sunday, June 30, 2002 and ends with Saturday, August 3, 2002.

パラメータ:
focus - 処理の対象となる日付
the date to work with
rangeStyle - スタイルを示す定数、 RANGE_MONTH_SUNDAYRANGE_MONTH_MONDAYRANGE_WEEK_SUNDAYRANGE_WEEK_MONDAYRANGE_WEEK_RELATIVERANGE_WEEK_CENTER の内のいずれかである必要があります
the style constant to use. Must be one of {@link DateUtils#RANGE_MONTH_SUNDAY}, {@link DateUtils#RANGE_MONTH_MONDAY}, {@link DateUtils#RANGE_WEEK_SUNDAY}, {@link DateUtils#RANGE_WEEK_MONDAY}, {@link DateUtils#RANGE_WEEK_RELATIVE}, {@link DateUtils#RANGE_WEEK_CENTER}
戻り値:
日付のイテレータ
the date iterator
例外:
IllegalArgumentException - date が null の場合
if the date is null

iterator

public static Iterator iterator(Object focus,
                                int rangeStyle)

焦点となる日付と範囲のスタイルから、日付の範囲を表現する Iterator を生成します。

This constructs an Iterator that will start and stop over a date range based on the focused date and the range style.

例えば、"Thursday, July 4, 2002" と RANGE_MONTH_SUNDAY を指定した場合、"Sunday, June 30,2002" で始まり、"Saturday, August 3, 2002" で終わる Iterator を返します。

For instance, passing Thursday, July 4, 2002 and a RANGE_MONTH_SUNDAY will return an Iterator that starts with Sunday, June 30, 2002 and ends with Saturday, August 3, 2002.

パラメータ:
focus - Date または Calendar で指定された処理の対象となる日付
the date to work with, either Date or Calendar
rangeStyle - スタイルを示す定数、iterator(Calendar, int) メソッドで示されるリスト内のどれかである必要があります。
the style constant to use. Must be one of the range styles listed for the {@link #iterator(Calendar, int)} method.
戻り値:
日付のイテレータ
the date iterator
例外:
IllegalArgumentException - date が null の場合
if the date is null
ClassCastException - object の型が Date または Calendar 以外だった場合
if the object type is not a Date or Calendar


このドキュメントは、Ja-Jakartaにより訳されました。 コメントがある場合は report@jajakarta.orgまでお願いします。
Translated into Japanese by jajakarta.org. The original page is here.
Copyright (c) 2002-2003 - Apache Software Foundation