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

java.lang.Object
  拡張java.text.Format
      拡張org.apache.commons.lang.time.FastDateFormat
すべての実装インタフェース:
Cloneable, Serializable

public class FastDateFormat
extends Format

FastDateFormat は高速に動作するスレッドセーフな SimpleDateFormat です。

FastDateFormat is a fast and thread-safe version of {@link java.text.SimpleDateFormat}.

このクラスは SimpleDateFormat を使用したフォーマットを行う大抵の処理をそのまま置き換えることが出来ます。 このクラスは特にマルチスレッドで動作するサーバ環境で有用です。 SimpleDateFormat は全ての JDK のバージョンにおいてスレッドセーフではなく、 Sun はこれをバグまたは要望として対応することもありません。

This class can be used as a direct replacement to SimpleDateFormat in most formatting situations. This class is especially useful in multi-threaded server environments. SimpleDateFormat is not thread-safe in any JDK version, nor will it be as Sun have closed the bug/RFE.

このクラスはフォーマットの処理にのみ対応しますが、全てのパターンのフォーマットの処理が SimpleDateFormat と互換性を持ちます(タイムゾーンを除いて - 以下を参照)。

Only formatting is supported, but all patterns are compatible with SimpleDateFormat (except time zones - see below).

Java 1.4 は RFC822 のフォーマットでタイムゾーンを表す 'Z' という新しいパターンの文字を取り入れました(例えば +0800-1100)。 このクラスでは(全ての JDK のバージョンで)この文字を使用することができます。

Java 1.4 introduced a new pattern letter, 'Z', to represent time zones in RFC822 format (eg. +0800 or -1100). This pattern letter can be used here (on all JDK versions).

加えて、 'ZZ' のパターンは ISO8601 のフルフォーマットのタイムゾーンを表します(例えば +08:00-11:00)。 これは Java 1.4 との多少の非互換性を招きますが、有用な機能を得ることとなります。

In addition, the pattern 'ZZ' has been made to represent ISO8601 full format time zones (eg. +08:00 or -11:00). This introduces a minor incompatability with Java 1.4, but at a gain of useful functionality.

導入されたバージョン:
2.0
バージョン:
$Id: FastDateFormat.java,v 1.1.1.1 2004/02/13 10:02:05 hioki Exp $
作成者:
TeaTrove project, Brian S O'Neill, Sean Schofield, Gary Gregory, Stephen Colebourne
関連項目:
直列化された形式
翻訳者:
日置 聡
翻訳状況:
初稿(校正者募集中)
翻訳更新日:
2003/09/22

入れ子クラスの概要
 
クラス java.text.Format から継承した入れ子クラス
Format.Field
 
フィールドの概要
static int FULL
          FULL ロケールに依存した日付または時間のフォーマットのための定数です。
static int LONG
          LONG ロケールに依存した日付または時間のフォーマットのための定数です。
static int MEDIUM
          MEDIUM ロケールに依存した日付または時間のフォーマットのための定数です。
static int SHORT
          SHORT ロケールに依存した日付または時間のフォーマットのための定数です。
 
コンストラクタの概要
protected FastDateFormat(String pattern, TimeZone timeZone, Locale locale)
          新たな FastDateFormat を生成します。
 
メソッドの概要
protected  StringBuffer applyRules(Calendar calendar, StringBuffer buf)
          指定されたカレンダーにルールを適用してフォーマットを実施します。
 boolean equals(Object obj)
          2つのオブジェクトが等しいかどうか比較します。
 String format(Calendar calendar)
          Calendar オブジェクトをフォーマットします。
 StringBuffer format(Calendar calendar, StringBuffer buf)
          Calendar オブジェクトをフォーマットし、指定された StringBuffer に出力します。
 String format(Date date)
          Date オブジェクトをフォーマットします。
 StringBuffer format(Date date, StringBuffer buf)
          Date オブジェクトをフォーマットし、指定された StringBuffer に出力します。
 StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos)
          Date オブジェクトまたは Calendar オブジェクトをフォーマットします。
static FastDateFormat getDateInstance(int style, TimeZone timeZone, Locale locale)
          指定されたスタイル、タイムゾーン、ロケールを用いて日付のフォーマッターインスタンスを取得します。
static FastDateFormat getDateTimeInstance(int dateStyle, int timeStyle, TimeZone timeZone, Locale locale)
          指定されたスタイル、タイムゾーン、ロケールを用いて日付/時間のフォーマッターインスタンスを取得します。
static FastDateFormat getInstance()
          デフォルトのロケールとデフォルトのパターンを用いてフォーマッターのインスタンスを取得します。
static FastDateFormat getInstance(String pattern)
          デフォルトのロケールと指定されたパターンを用いてフォーマッターのインスタンスを取得します。
static FastDateFormat getInstance(String pattern, Locale locale)
          指定されたパターンと指定されたロケールを用いてフォーマッターのインスタンスを取得します。
static FastDateFormat getInstance(String pattern, TimeZone timeZone)
          指定されたパターンと指定されたタイムゾーンを用いてフォーマッターのインスタンスを取得します。
static FastDateFormat getInstance(String pattern, TimeZone timeZone, Locale locale)
          指定されたパターン、タイムゾーン、ロケールを用いてフォーマッターのインスタンスを取得します。
 Locale getLocale()
          このフォーマッターで使用されるロケールを取得します。
 int getMaxLengthEstimate()
          このフォーマッターが生成する文字列の最大長の見積もりを返します。
 String getPattern()
          このフォーマッターで使用されるパターンを取得します。
static FastDateFormat getTimeInstance(int style, TimeZone timeZone, Locale locale)
          指定されたスタイル、タイムゾーン、ロケールを用いて時間のフォーマッターインスタンスを取得します。
 TimeZone getTimeZone()
          このフォーマッターで使用されるタイムゾーンを取得します。
 boolean getTimeZoneOverridesCalendar()
          カレンダーのタイムゾーンがフォーマッターに上書きされる場合、 true を返します。
 int hashCode()
          適切なハッシュコードです。
protected  void init()
          最初に使用される際のインスタンスの初期化を行います。
 Object parseObject(String source, ParsePosition pos)
          パース処理はサポートされません。
protected  List parsePattern()
          パターンから生成された Rule のリストを返します。
protected  String parseToken(String pattern, int[] indexRef)
          トークンのパースを行います。
protected  org.apache.commons.lang.time.FastDateFormat.NumberRule selectNumberRule(int field, int padding)
          要求されたパディングに対する適切なルールを返します。
 String toString()
          このフォーマッターを説明するデバッグのための文字列
Gets a debugging string version of this formatter.
 
クラス java.text.Format から継承したメソッド
clone, format, formatToCharacterIterator, parseObject
 
クラス java.lang.Object から継承したメソッド
finalize, getClass, notify, notifyAll, wait, wait, wait
 

フィールドの詳細

FULL

public static final int FULL
FULL ロケールに依存した日付または時間のフォーマットのための定数です。
FULL locale dependent date or time style.

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

LONG

public static final int LONG
LONG ロケールに依存した日付または時間のフォーマットのための定数です。
LONG locale dependent date or time style.

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

MEDIUM

public static final int MEDIUM
MEDIUM ロケールに依存した日付または時間のフォーマットのための定数です。
MEDIUM locale dependent date or time style.

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

SHORT

public static final int SHORT
SHORT ロケールに依存した日付または時間のフォーマットのための定数です。
SHORT locale dependent date or time style.

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

FastDateFormat

protected FastDateFormat(String pattern,
                         TimeZone timeZone,
                         Locale locale)

新たな FastDateFormat を生成します。

Constructs a new FastDateFormat.

パラメータ:
pattern - SimpleDateFormat と互換性のあるパターン
{@link java.text.SimpleDateFormat} compatible pattern
timeZone - 使用されるタイムゾーン、 null が指定された場合、 DateCalendar に対してデフォルトの値が使用されます
time zone to use, null means use default for Date and value within for Calendar
locale - 使用されるロケール、 null が指定された場合、システムのデフォルトが使用されます
locale, null means use system default
例外:
IllegalArgumentException - パターンが不正または null の場合
if pattern is invalid or null
メソッドの詳細

getInstance

public static FastDateFormat getInstance()

デフォルトのロケールとデフォルトのパターンを用いてフォーマッターのインスタンスを取得します。

Gets a formatter instance using the default pattern in the default locale.

戻り値:
日付/時間のフォーマッター
a date/time formatter

getInstance

public static FastDateFormat getInstance(String pattern)

デフォルトのロケールと指定されたパターンを用いてフォーマッターのインスタンスを取得します。

Gets a formatter instance using the specified pattern in the default locale.

パラメータ:
pattern - SimpleDateFormat と互換性のあるパターン
{@link java.text.SimpleDateFormat} compatible pattern
戻り値:
パターンをベースにした日付/時間のフォーマッター
a pattern based date/time formatter
例外:
IllegalArgumentException - パターンが不正な場合
if pattern is invalid

getInstance

public static FastDateFormat getInstance(String pattern,
                                         TimeZone timeZone)

指定されたパターンと指定されたタイムゾーンを用いてフォーマッターのインスタンスを取得します。

Gets a formatter instance using the specified pattern and time zone.

パラメータ:
pattern - SimpleDateFormat と互換性のあるパターン
{@link java.text.SimpleDateFormat} compatible pattern
timeZone - フォーマットされた日付のタイムゾーンを上書きする任意のタイムゾーン
optional time zone, overrides time zone of formatted date
戻り値:
パターンをベースにした日付/時間のフォーマッター
a pattern based date/time formatter
例外:
IllegalArgumentException - パターンが不正な場合
if pattern is invalid

getInstance

public static FastDateFormat getInstance(String pattern,
                                         Locale locale)

指定されたパターンと指定されたロケールを用いてフォーマッターのインスタンスを取得します。

Gets a formatter instance using the specified pattern and locale.

パラメータ:
pattern - SimpleDateFormat と互換性のあるパターン
{@link java.text.SimpleDateFormat} compatible pattern
locale - システムのロケールを上書きする任意のロケール
optional locale, overrides system locale
戻り値:
パターンをベースにした日付/時間のフォーマッター
a pattern based date/time formatter
例外:
IllegalArgumentException - パターンが不正な場合
if pattern is invalid

getInstance

public static FastDateFormat getInstance(String pattern,
                                         TimeZone timeZone,
                                         Locale locale)

指定されたパターン、タイムゾーン、ロケールを用いてフォーマッターのインスタンスを取得します。

Gets a formatter instance using the specified pattern, time zone and locale.

パラメータ:
pattern - SimpleDateFormat と互換性のあるパターン
{@link java.text.SimpleDateFormat} compatible pattern
timeZone - フォーマットされた日付のタイムゾーンを上書きする任意のタイムゾーン
optional time zone, overrides time zone of formatted date
locale - システムのロケールを上書きする任意のロケール
optional locale, overrides system locale
戻り値:
パターンをベースにした日付/時間のフォーマッター
a pattern based date/time formatter
例外:
パターンが不正または - null な場合
IllegalArgumentException if pattern is invalid or null

getDateInstance

public static FastDateFormat getDateInstance(int style,
                                             TimeZone timeZone,
                                             Locale locale)

指定されたスタイル、タイムゾーン、ロケールを用いて日付のフォーマッターインスタンスを取得します。

Gets a date formatter instance using the specified style, time zone and locale.

パラメータ:
style - 日付のスタイル:FULL または LONG または MEDIUM または SHORT
date style: FULL, LONG, MEDIUM, or SHORT
timeZone - フォーマットされた日付のタイムゾーンを上書きする任意のタイムゾーン
optional time zone, overrides time zone of formatted date
locale - システムのロケールを上書きする任意のロケール
optional locale, overrides system locale
戻り値:
ローカライズされた標準の日付のフォーマッター
a localized standard date formatter
例外:
IllegalArgumentException - ロケールが定義された日付のパターンを持っていない場合
if the Locale has no date pattern defined

getTimeInstance

public static FastDateFormat getTimeInstance(int style,
                                             TimeZone timeZone,
                                             Locale locale)

指定されたスタイル、タイムゾーン、ロケールを用いて時間のフォーマッターインスタンスを取得します。

Gets a time formatter instance using the specified style, time zone and locale.

パラメータ:
style - 時間のスタイル:FULL または LONG または MEDIUM または SHORT
time style: FULL, LONG, MEDIUM, or SHORT
timeZone - フォーマットされた日付のタイムゾーンを上書きする任意のタイムゾーン
optional time zone, overrides time zone of formatted date
locale - システムのロケールを上書きする任意のロケール
optional locale, overrides system locale
戻り値:
ローカライズされた標準の時間のフォーマッター
a localized standard time formatter
例外:
IllegalArgumentException - ロケールが定義された時間のパターンを持っていない場合
if the Locale has no time pattern defined

getDateTimeInstance

public static FastDateFormat getDateTimeInstance(int dateStyle,
                                                 int timeStyle,
                                                 TimeZone timeZone,
                                                 Locale locale)

指定されたスタイル、タイムゾーン、ロケールを用いて日付/時間のフォーマッターインスタンスを取得します。

Gets a date/time formatter instance using the specified style, time zone and locale.

パラメータ:
dateStyle - 日付のスタイル:FULL または LONG または MEDIUM または SHORT
date style: FULL, LONG, MEDIUM, or SHORT
timeStyle - 時間のスタイル:FULL または LONG または MEDIUM または SHORT
time style: FULL, LONG, MEDIUM, or SHORT
timeZone - フォーマットされた日付のタイムゾーンを上書きする任意のタイムゾーン
optional time zone, overrides time zone of formatted date
locale - システムのロケールを上書きする任意のロケール
optional locale, overrides system locale
戻り値:
a localized standard date/time formatter
例外:
IllegalArgumentException - ロケールが定義された日付/時間のパターンを持っていない場合
if the Locale has no date/time pattern defined

init

protected void init()

最初に使用される際のインスタンスの初期化を行います。

Initialise the instance for first use.


parsePattern

protected List parsePattern()

パターンから生成された Rule のリストを返します。

Returns a list of Rules given a pattern.

戻り値:
Rule オブジェクトの List
a List of Rule objects
例外:
IllegalArgumentException - パターンが不正な場合
if pattern is invalid

parseToken

protected String parseToken(String pattern,
                            int[] indexRef)

トークンのパースを行います。

Performs the parsing of tokens.

パラメータ:
pattern - パターン
the pattern
indexRef - 参照のインデックス
index references
戻り値:
パースされたトークン
parsed token

selectNumberRule

protected org.apache.commons.lang.time.FastDateFormat.NumberRule selectNumberRule(int field,
                                                                                  int padding)

要求されたパディングに対する適切なルールを返します。

Gets an appropriate rule for the padding required.

パラメータ:
field - ルールを取得する対象となるフィールド
the field to get a rule for
padding - 要求されたパディング
the padding required
戻り値:
パディングに対応する新たなルール
a new rule with the correct padding

format

public StringBuffer format(Object obj,
                           StringBuffer toAppendTo,
                           FieldPosition pos)

Date オブジェクトまたは Calendar オブジェクトをフォーマットします。

Format either a Date or a Calendar object.

パラメータ:
obj - フォーマットの対象となるオブジェクト
the object to format
toAppendTo - 書き込み先となるバッファ
the buffer to append to
pos - フォーマットする位置 - 無効
the position - ignored
戻り値:
フォーマットの結果が出力されたバッファ
the buffer passed in

format

public String format(Date date)

Date オブジェクトをフォーマットします。

Formats a Date object.

パラメータ:
date - フォーマットの対象となる日付
the date to format
戻り値:
フォーマットされた文字列
the formatted string

format

public String format(Calendar calendar)

Calendar オブジェクトをフォーマットします。

Formats a Calendar object.

パラメータ:
calendar - フォーマットの対象となるカレンダー
the calendar to format
戻り値:
フォーマットされた文字列
the formatted string

format

public StringBuffer format(Date date,
                           StringBuffer buf)

Date オブジェクトをフォーマットし、指定された StringBuffer に出力します。

Formats a Date object into the supplied StringBuffer.

パラメータ:
date - フォーマットの対象となる日付
the date to format
buf - 書き込み先となるバッファ
the buffer to append to
戻り値:
指定された文字列のバッファ
the specified string buffer

format

public StringBuffer format(Calendar calendar,
                           StringBuffer buf)

Calendar オブジェクトをフォーマットし、指定された StringBuffer に出力します。

Formats a Calendar object into the supplied StringBuffer.

パラメータ:
calendar - フォーマットの対象となるカレンダー
the calendar to format
buf - 書き込み先となるバッファ
the buffer to append to
戻り値:
指定された文字列のバッファ
the specified string buffer

applyRules

protected StringBuffer applyRules(Calendar calendar,
                                  StringBuffer buf)

指定されたカレンダーにルールを適用してフォーマットを実施します。

Performs the formatting by applying the rules to the specified calendar.

パラメータ:
calendar - フォーマットの対象となるカレンダー
the calendar to format
buf - 書き込み先となるバッファ
the buffer to append to
戻り値:
指定された文字列のバッファ
the specified string buffer

parseObject

public Object parseObject(String source,
                          ParsePosition pos)

パース処理はサポートされません。

Parsing not supported.

パラメータ:
source - パースの対象となる文字列
the string to parse
pos - パーすする位置
the parsing position
戻り値:
サポートされないため、null
null as not supported

getPattern

public String getPattern()

このフォーマッターで使用されるパターンを取得します。

Gets the pattern used by this formatter.

戻り値:
SimpleDateFormat と互換性のあるパターン
the pattern, {@link java.text.SimpleDateFormat} compatible

getTimeZone

public TimeZone getTimeZone()

このフォーマッターで使用されるタイムゾーンを取得します。

Gets the time zone used by this formatter.

このタイムゾーンは常時 Date のフォーマットに使用されます。 Calendar がフォーマットのために渡された場合、このタイムゾーンは getTimeZoneOverridesCalendar() の結果に応じて使用されます。

This zone is always used for Date formatting. If a Calendar is passed in to be formatted, the time zone on that may be used depending on {@link #getTimeZoneOverridesCalendar()}.

戻り値:
タイムゾーン
the time zone

getTimeZoneOverridesCalendar

public boolean getTimeZoneOverridesCalendar()

カレンダーのタイムゾーンがフォーマッターに上書きされる場合、 true を返します。

Returns true if the time zone of the calendar overrides the time zone of the formatter.

戻り値:
カレンダーのタイムゾーンがフォーマッターに上書きされる場合、 true
true if time zone of formatter overridden for calendars

getLocale

public Locale getLocale()

このフォーマッターで使用されるロケールを取得します。

Gets the locale used by this formatter.

戻り値:
ロケール
the locale

getMaxLengthEstimate

public int getMaxLengthEstimate()

このフォーマッターが生成する文字列の最大長の見積もりを返します。

Gets an estimate for the maximum string length that the formatter will produce.

実際のフォーマットされた文字の長さはほとんどの場合、この長さ以下です。

The actual formatted length will almost always be less than or equal to this amount.

戻り値:
フォーマットされた文字列の最大長
the maximum formatted length

equals

public boolean equals(Object obj)

2つのオブジェクトが等しいかどうか比較します。

Compare two objects for equality.

パラメータ:
obj - 比較対照となるオブジェクト
the object to compare to
戻り値:
等しい場合、true
true if equal

hashCode

public int hashCode()

適切なハッシュコードです。

A suitable hashcode.

戻り値:
equals と互換性のあるハッシュコード
a hashcode compatable with equals

toString

public String toString()

このフォーマッターを説明するデバッグのための文字列

Gets a debugging string version of this formatter.

戻り値:
a debugging string


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