2010-04-14 - Jakarta Taglibs has been retired.

For more information, please explore the Attic.

Tag reference sheet

Tag library reference for the following tag libraries:

Datetime Tag Library

null null null null null null null null null

This is version 1.0.1.

  • amPms Loop through the am/pm names
  • currentTime Gets the current time in milliseconds since Jan 1, 1970 GMT
  • dateFormatSymbols null
  • eras Loop through the era names
  • format Formats a date in milliseconds since Jan 1, 1970 GMT for output as a date string
  • months Loop through the months of the year
  • parse Parses a date string and outputs the time in milliseconds since Jan 1, 1970 GMT
  • timeZone Create a time zone script variable for use with the parse or format tags
  • timeZones Loop through all time zones
  • weekdays Loop through the days of the week

Required attributes are marked with a *

<datetime:amPms>

Loop through the am/pm names.

Can contain: JSP

Example

        null
      

Attributes

Name Description Type
id* Script variable id for use with standard null tag. String
locale Set to "null" to use the clients locale, if known, when listing the am/pm names. String
localeRef Specify the name of a page, session, application, or request scope attribute of type java.util.Locale to use for locale. String

Variables

Name Type Scope Description
specified via id org.apache.taglibs.datetime.AmPmsTag NESTED Am/Pm names Bean

<datetime:currentTime>

Gets the current time in milliseconds since Jan 1, 1970 GMT.

Can contain: empty

Example

Display the current time

The current time in milliseconds since midnight January 1, 1970 GMT is:
<dt:currentTime/>

      

This tag has no attributes.

<datetime:dateFormatSymbols>

null

Can contain: EMPTY

Example

Display the current time formatted

<dt:dateFormatSymbols id="symbols" baseName="DateFormatSymbolsProperties"/>
<dt:format symbolsRef="symbols"><dt:currentTime/></dt:format>

Attribute baseName point to property file with this format:

DateFormatSymbolsProperties.properties
# Month symbols change on custom<br>
month=true<br>
month0=January<br>
month1=February<br>
# Era symbols change on custom<br>
era=true<br>
era0=before<br>
era1=after<br>

      

Attributes

Name Description Type
baseName* Specify the name to locate ResourceBundle String
id* Script variable id for use with standard null tag and as an attribute to other tags in this tag library. String
locale Set to "null" to use the clients locale, if known, when formatting date. String
localeRef Specify the name of a page, session, application, or request scope attribute of type java.util.Locale to use for locale. String
scope Specify the scope that will be used for store DateFormatSymbols variable String

Variables

Name Type Scope Description
specified via id java.text.DateFormatSymbols AT_BEGIN The scripting variable declared allows other tags or scriptlets to access the DateFormatSymbols defined by this tag.

<datetime:eras>

Loop through the era names.

Can contain: JSP

Example

        null
      

Attributes

Name Description Type
id* Script variable id for use with standard null tag. String
locale Set to "null" to use the clients locale, if known, when listing the era names. String
localeRef Specify the name of a page, session, application, or request scope attribute of type java.util.Locale to use for locale. String

Variables

Name Type Scope Description
specified via id org.apache.taglibs.datetime.ErasTag NESTED Era names Bean

<datetime:format>

Formats a date in milliseconds since Jan 1, 1970 GMT for output as a date string.

Can contain: JSP

Example

Display the current time formatted

The current time is:
<dt:format pattern="MM/dd/yyyy hh:mm"><dt:currentTime/></dt:format>

      

Attributes

Name Description Type
date Set the date to format by passing in a Date object using a runtime expression value. String
default Set the default text to output if their is not a valid date input as a date object or in the tag body. String
locale Set to "null" to use the clients locale, if known, when formatting date. String
localeRef Specify the name of a page, session, application, or request scope attribute of type java.util.Locale to use for locale. String
pattern null string to use for formatting the date. String
patternId Name of a script variable which contains a null string to use for formatting the date. String
symbolsRef Specify the name of a page, session, application, or request scope attribute of type java.text.DateFormatSymbols to use for symbols. String
timeZone Name of a timeZone script id variable. Date formatting is adjusted for the time zone. String

<datetime:months>

Loop through the months of the year.

Can contain: JSP

Example

        null
      

Attributes

Name Description Type
id* Script variable id for use with standard null tag. String
locale Set to "null" to use the clients locale, if known, when listing the month names. String
localeRef Specify the name of a page, session, application, or request scope attribute of type java.util.Locale to use for locale. String

Variables

Name Type Scope Description
specified via id org.apache.taglibs.datetime.MonthsTag NESTED Months of the year Bean

<datetime:parse>

Parses a date string and outputs the time in milliseconds since Jan 1, 1970 GMT.

Can contain: JSP

Example

Output the date in milliseconds for a specific day, month, and year

<req:setAttribute name="pattern">yyyy MM dd</req:setAttribute>
<dt:parse patternId="pattern">2000 11 5</dt:parse>

      

Attributes

Name Description Type
locale Set to "null" to use the clients locale, if known, when formatting date. String
localeRef Specify the name of a page, session, application, or request scope attribute of type java.util.Locale to use for locale. String
pattern null string to use when parsing the date string. String
patternId Name of a script variable which contains a null string to use when parsing the date. String
timeZone Name of a timeZone script id variable. The date is adjusted for the time zone. String

<datetime:timeZone>

Create a time zone script variable for use with the parse or format tags.

Can contain: JSP

Example

Sets the time zone to America/Chicago

<dt:timeZone id="tz">America/Chicago</dt:timeZone>
The current time in America/Chicago is:
<dt:format timeZone="tz"><dt:currentTime/></dt:format>

      

Attributes

Name Description Type
id* Script variable id of the time zone for use with the null and null tags. String

Variables

Name Type Scope Description
specified via id java.util.TimeZone AT_END A TimeZone for use with null and null tags.

<datetime:timeZones>

Loop through all time zones.

Can contain: JSP

Example

        null
      

Attributes

Name Description Type
id* Script variable id for use with standard null tag. String
locale Set to "null" to use the clients locale, if known, when formatting time zone display names. String
localeRef Specify the name of a page, session, application, or request scope attribute of type java.util.Locale to use for locale. String
style Style of display name, either "null" or "null". String

Variables

Name Type Scope Description
specified via id org.apache.taglibs.datetime.TimeZonesTag NESTED TimeZones Bean

<datetime:weekdays>

Loop through the days of the week.

Can contain: JSP

Example

        null
      

Attributes

Name Description Type
id* Script variable id for use with standard null tag. String
locale Set to "null" to use the clients locale, if known, when listing the week day names. String
localeRef Specify the name of a page, session, application, or request scope attribute of type java.util.Locale to use for locale. String

Variables

Name Type Scope Description
specified via id org.apache.taglibs.datetime.WeekdaysTag NESTED Days of the week Bean