The Jakarta Project < Velocity Tools - Library >

Velocity Tools

Generic Tools

ツールドキュメント

その他のサブプロジェクト

DateTool リファレンスドキュメント
       

Tool for accessing, manipulating, and convertingjava.util.Date and java.util.Calendar objects in Velocity templates. It supports locales to format dates language and country specific.

Velocity テンプレート内で、java.util.Datejava.util.Calendar オブジェクトへのアクセス、 操作、変換を行うツールです。 言語や国特有の日付フォーマットのためのロカールをサポートしています。

Class
 org.apache.velocity.tools.generic.DateTool
Name
 $date (Velocityコンテキスト内での推奨名)
Toolbox設定例
 
<tool>
  <key>date</key>
  <scope>application</scope>
  <class>org.apache.velocity.tools.generic.DateTool</class>
</tool>
作者
 Nathan Bubna
Method Overview
getDate() Returns a Date object representing the time at which this method was invoked.
getCalendar() Returns a Calendar object representing the time at which this method was invoked.
format() Returns a formatted string representing the specified date.
toDate() Returns a Date object representing the specified date.
toCalendar() Returns a Calendar object representing the specified date.
Method Overview
getDate() メソッドが呼び出された時点での時間を表す Date オブジェクトを返却します。
getCalendar() メソッドが呼び出された時点での時間を表す Calender オブジェクトを返却します。
format() 指定された日付をフォーマットした文字列を返却します。
toDate() 指定された日付を表す Date オブジェクトを返却します。
toCalendar() 指定された日付を表す Calendar オブジェクトを返却します。
getDate()
       

Returns a Date object representing the time at which this method was invoked.

String getDate()

String getDate(Locale locale)

Parameters
locale
An object of class java.util.Locale that represents the locale to be used to create the date.
Returns
An object of class java.util.Date representing the time at which this method was invoked in the specified locale. If no locale is specified, the system's default locale is used.

メソッドが呼び出された時点での時間を表す Date オブジェクトを返却します。

String getDate()

String getDate(Locale locale)

Parameters
locale
Date を作成するのに使用されるロカールを示す java.util.Locale クラスのオブジェクト。
Returns
指定されたロカールでの、メソッドが呼び出された時点での時間を表す java.util.Date クラスのオブジェクトを返却します。 ロカールが指定されなかった場合、システムのデフォルトロカールが使用されます。

getCalendar()
       

Returns a Calendar object representing the time at which this method was invoked.

String getCalendar()

String getCalendar(Locale locale)

Parameters
locale
An object of class java.util.Locale that represents the locale to be used to create the calendar.
Returns
An object of class java.util.Calendar representing the time at which this method was invoked in the specified locale. If no locale is specified, the system's default locale is used.

メソッドが呼び出された時点での時間を表す Calender オブジェクトを返却します。

String getCalendar()

String getCalendar(Locale locale)

Parameters
locale
Calender を作成するのに使用されるロカールを示す java.util.Locale クラスのオブジェクト。
Returns
指定されたロカールでの、メソッドが呼び出された時点での時間を表す java.util.Calendar クラスのオブジェクトを返却します。 ロカールが指定されなかった場合、システムのデフォルトロカールが使用されます。

format()
       

Returns a formatted string representing the specified date.

String format(String format, Object obj)

String format(String format, Object obj, Locale locale)

Parameters
format
A string that represents the formatting instructions according to java.text.SimpleDateFormat. See also below.
obj
An object of class java.util.Date or java.util.Calendar. It is also possible to pass a string that represents a parsable date according to java.text.DateFormat.
locale
An object of class java.util.Locale that represents the locale to format the date for.
Returns
The formatted date string in the specified locale or null if one or several input parameters are invalid. If no locale is specified, the system's default locale is used instead.

This methods use the same formatting instructions as class java.text.SimpleDateFormat.


Symbol   Meaning                 Presentation        Example
------   -------                 ------------        -------
G        era designator          (Text)              AD
y        year                    (Number)            1996
M        month in year           (Text & Number)     July & 07
d        day in month            (Number)            10
h        hour in am/pm (1~12)    (Number)            12
H        hour in day (0~23)      (Number)            0
m        minute in hour          (Number)            30
s        second in minute        (Number)            55
S        millisecond             (Number)            978
E        day in week             (Text)              Tuesday
D        day in year             (Number)            189
F        day of week in month    (Number)            2 (2nd Wed in July)
w        week in year            (Number)            27
W        week in month           (Number)            2
a        am/pm marker            (Text)              PM
k        hour in day (1~24)      (Number)            24
K        hour in am/pm (0~11)    (Number)            0
z        time zone               (Text)              Pacific Standard Time
'        escape for text         (Delimiter)
''       single quote            (Literal)           '     

Examples: "E, MMMM d" will result in "Tue, July 24"
          "EEE, M-d (H:m)" will result in "Tuesday, 7-24 (14:12)"

指定された日付をフォーマットした文字列を返却します。

String format(String format, Object obj)

String format(String format, Object obj, Locale locale)

Parameters
format
java.text.SimpleDateFormat に従ったフォーマット指定を表す String 。以下を参照してください。
obj
java.util.Date または java.util.Calendar クラスのオブジェクト。 java.text.DateFormat に従って解析可能な日付を表す String でも可。
locale
日付のフォーマットに使用されるロカールを示す java.util.Locale クラスのオブジェクト。
Returns
指定されたロカールでフォーマットされた日付を表す String 。 引数に不正なものが含まれていた場合は null 。 ロカールが指定されなかった場合、システムのデフォルトロカールが使用されます。

このメソッドは java.text.SimpleDateFormat クラスと同じフォーマット指定を使用します。


Symbol   Meaning                 Presentation        Example
------   -------                 ------------        -------
G        年号                    (Text)              AD
y        年                      (Number)            1996
M        月                      (Text & Number)     July & 07
d        月における日             (Number)            10
h        午前/午後の時(1-12)      (Number)            12
H        一日における時(0-23)     (Number)            0
m        分                      (Number)            30
s        秒                      (Number)            55
S        ミリ秒                  (Number)            978
E        曜日                    (Text)              Tuesday
D        年における日             (Number)            189
F        月における曜日           (Number)            2 (2nd Wed in July)
w        年における週             (Number)            27
W        月における週             (Number)            2
a        午前/午後               (Text)              PM
k        一日における時(1-24)     (Number)            24
K        午前/午後の時(0-11)      (Number)            0
z        タイムゾーン            (Text)              Pacific Standard Time
'        テキストのエスケープ     (Delimiter)
''       シングルクオート         (Literal)           '     

例: "E, MMMM d" は "Tue, July 24" となり、
    "EEE, M-d (H:m)" は "Tuesday, 7-24 (14:12)" となります。

toDate()
       

Returns a Date object representing the specified date.

Date toDate(Object obj)

Parameters
obj
The date to convert. The parameter can be an object of class java.util.Date or java.util.Calendar. It is also possible to pass a string that represents a parsable date according to java.text.DateFormat.
Returns
An object of class java.util.Date representing the converted date or of the input parameter is invalid.

指定された日付を表す Date オブジェクトを返却します。

Date toDate(Object obj)

Parameters
obj
変換する日付。 パラメータは java.util.Date または java.util.Calendar クラスのオブジェクト。 java.text.DateFormat に従って解析可能な日付を表す String でも可。
Returns
変換された日付を表す java.util.Date クラスのオブジェクト。 パラメータが不正の場合は null

toCalendar()
       

Returns a Calendar object representing the specified date.

Calendar toCalendar(Object obj)

Parameters
obj
The date to convert. The parameter can be an object of class java.util.Date or java.util.Calendar. It is also possible to pass a string that represents a parsable date according to java.text.DateFormat.
Returns
An object of class java.util.Calendar representing the converted date or of the input parameter is invalid.

指定された日付を表す Calendar オブジェクトを返却します。

Calendar toCalendar(Object obj)

Parameters
obj
変換する日付。 パラメータは java.util.Date または java.util.Calendar クラスのオブジェクト。 java.text.DateFormat に従って解析可能な日付を表す String でも可。
Returns
変換された日付を表す java.util.Calendar クラスのオブジェクト。 パラメータが不正の場合は null


[訳注: この文書は 木村 貴由 高橋 達男 が翻訳しました。 日本語訳に対するコメントがあれば、report@jajakarta.orgに送って下さい。]
Copyright © 1999-2003, Apache Software Foundation