1.0.1 1.1 datetime http://jakarta.apache.org/taglibs/datetime-1.0 Datetime Tag Library

The DATETIME custom tag library contains tags which can be used to handle date and time related functions.

Tags are provided for formatting a Date for output, generating a Date from HTML form input, using time zones, and localization.

To specify the time format use a time pattern string. In this pattern, all ASCII letters are reserved as pattern letters, which are defined as the following:

 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)          '
 
The count of pattern letters determine the format.

(Text): 4 or more pattern letters--use full form, < 4--use short or abbreviated form if one exists.

(Number): the minimum number of digits. Shorter numbers are zero-padded to this amount. Year is handled specially; that is, if the count of 'y' is 2, the Year will be truncated to 2 digits.

(Text & Number): 3 or over, use text, otherwise use number.

Any characters in the pattern that are not in the ranges of ['a'..'z'] and ['A'..'Z'] will be treated as quoted text. For instance, characters like ':', '.', ' ', '#' and '@' will appear in the resulting time text even they are not embraced within single quotes.

A pattern containing any invalid pattern letter will result in a thrown exception during formatting or parsing.

Examples Using the US Locale:

 Format Pattern                    Result
 --------------                    -------
 "yyyy.MM.dd G 'at' hh:mm:ss z"    1996.07.10 AD at 15:08:56 PDT
 "EEE, MMM d, ''yy"                Wed, July 10, '96
 "h:mm a"                          12:08 PM
 "hh 'o''clock' a, zzzz"           12 o'clock PM, Pacific Daylight Time
 "K:mm a, z"                       0:00 PM, PST
 "yyyyy.MMMMM.dd GGG hh:mm aaa"    1996.July.10 AD 12:08 PM
 

currentTime org.apache.taglibs.datetime.CurrentTimeTag empty currentTime Gets the current time in milliseconds since Jan 1, 1970 GMT. Gets the current time in milliseconds since Jan 1, 1970 GMT. Display the current time ]]> format org.apache.taglibs.datetime.FormatTag JSP format Formats a date in milliseconds since Jan 1, 1970 GMT for output as a date string. The body of the tag must be a Date in milliseconds since Jan 1, 1970 GMT. Formats a date in milliseconds since Jan 1, 1970 GMT for output as a date string. pattern no no Date Time Pattern Format string to use for formatting the date. patternId no no Name of a script variable which contains a Date Time Pattern Format string to use for formatting the date. timeZone no no Name of a timeZone script id variable. Date formatting is adjusted for the time zone. date no yes Set the date to format by passing in a Date object using a runtime expression value. symbolsRef no yes Specify the name of a page, session, application, or request scope attribute of type java.text.DateFormatSymbols to use for symbols. default no no Set the default text to output if their is not a valid date input as a date object or in the tag body. locale no no Set to "true" to use the clients locale, if known, when formatting date. localeRef false false Specify the name of a page, session, application, or request scope attribute of type java.util.Locale to use for locale. Display the current time formatted ]]> dateFormatSymbols org.apache.taglibs.datetime.DateFormatSymbolsTag org.apache.taglibs.datetime.DateFormatSymbolsTEI EMPTY dateFormatSymbols

Create DateFormatSymbols object that will be used for formating.

Parses a date string and outputs the time in milliseconds since Jan 1, 1970 GMT. This tag must be placed early in the page (before call of format tag with symbolsRef attribute) id java.text.DateFormatSymbols true AT_BEGIN The scripting variable declared allows other tags or scriptlets to access the DateFormatSymbols defined by this tag. id true true Script variable id for use with standard jsp:getProperty tag and as an attribute to other tags in this tag library. baseName true true Specify the name to locate ResourceBundle locale no no Set to "true" to use the clients locale, if known, when formatting date. localeRef false false Specify the name of a page, session, application, or request scope attribute of type java.util.Locale to use for locale. scope false false Specify the scope that will be used for store DateFormatSymbols variable Display the current time formatted Attribute baseName point to property file with this format: DateFormatSymbolsProperties.properties # Month symbols change on custom
month=true
month0=January
month1=February
# Era symbols change on custom
era=true
era0=before
era1=after
]]>
parse org.apache.taglibs.datetime.ParseTag JSP parse Parses a date string and outputs the time in milliseconds since Jan 1, 1970 GMT. Parses a date string and outputs the time in milliseconds since Jan 1, 1970 GMT. The body of the tag is used as the Date string to parse. pattern no no Date Time Pattern Format string to use when parsing the date string. patternId no no Name of a script variable which contains a Date Time Pattern Format string to use when parsing the date. timeZone no no Name of a timeZone script id variable. The date is adjusted for the time zone. locale no no Set to "true" to use the clients locale, if known, when formatting date. localeRef false false Specify the name of a page, session, application, or request scope attribute of type java.util.Locale to use for locale. Output the date in milliseconds for a specific day, month, and year yyyy MM dd 2000 11 5 ]]> timeZone org.apache.taglibs.datetime.TimeZoneTag JSP timeZone Create a time zone script variable for use with the parse or format tags. Create a time zone script variable for use with the parse or format tags. The body of the tag must be empty or a valid time zone ID. If a valid time zone ID is not found, the default time zone for the server is used. id java.util.TimeZone true AT_END A TimeZone for use with parse and format tags. id true false Script variable id of the time zone for use with the parse and format tags. Sets the time zone to America/Chicago America/Chicago The current time in America/Chicago is: ]]> timeZones org.apache.taglibs.datetime.TimeZonesTag org.apache.taglibs.datetime.TimeZonesTEI JSP timeZones Loop through all time zones. Loop through all time zones. id org.apache.taglibs.datetime.TimeZonesTag true NESTED TimeZones Bean zoneId Yes No Returns the current time zone ID. displayName Yes No Returns the current time zone display name. id true false Script variable id for use with standard jsp:getProperty tag. locale false false Set to "true" to use the clients locale, if known, when formatting time zone display names. localeRef false false Specify the name of a page, session, application, or request scope attribute of type java.util.Locale to use for locale. style false false Style of display name, either "SHORT" or "LONG". Generate a time zone select box ]]> months org.apache.taglibs.datetime.MonthsTag org.apache.taglibs.datetime.MonthsTEI JSP months Loop through the months of the year. Loop through the months of the year. id org.apache.taglibs.datetime.MonthsTag true NESTED Months of the year Bean monthOfYear Yes No Returns the number of the month of the year. month Yes No Returns the full name of the month of the year. shortMonth Yes No Returns the short name of the month of the year. id true false Script variable id for use with standard jsp:getProperty tag. locale false false Set to "true" to use the clients locale, if known, when listing the month names. localeRef false false Specify the name of a page, session, application, or request scope attribute of type java.util.Locale to use for locale. Generate a Month select box ]]> weekdays org.apache.taglibs.datetime.WeekdaysTag org.apache.taglibs.datetime.WeekdaysTEI JSP weekdays Loop through the days of the week. Loop through the days of the week. id org.apache.taglibs.datetime.WeekdaysTag true NESTED Days of the week Bean dayOfWeek Yes No Returns the number of the day of the week. weekday Yes No Returns the full name of the day of the week. shortWeekday Yes No Returns the short name of the day of the week. id true false Script variable id for use with standard jsp:getProperty tag. locale false false Set to "true" to use the clients locale, if known, when listing the week day names. localeRef false false Specify the name of a page, session, application, or request scope attribute of type java.util.Locale to use for locale. Generate a Week Day select box ]]> amPms org.apache.taglibs.datetime.AmPmsTag org.apache.taglibs.datetime.AmPmsTEI JSP amPms Loop through the am/pm names. Loop through the am/pm names. id org.apache.taglibs.datetime.AmPmsTag true NESTED Am/Pm names Bean name Yes No Returns the am/pm name. id true false Script variable id for use with standard jsp:getProperty tag. locale false false Set to "true" to use the clients locale, if known, when listing the am/pm names. localeRef false false Specify the name of a page, session, application, or request scope attribute of type java.util.Locale to use for locale. Generate an am/pm select box ]]> eras org.apache.taglibs.datetime.ErasTag org.apache.taglibs.datetime.ErasTEI JSP eras Loop through the era names. Loop through the era names. id org.apache.taglibs.datetime.ErasTag true NESTED Era names Bean name Yes No Returns the era name. id true false Script variable id for use with standard jsp:getProperty tag. locale false false Set to "true" to use the clients locale, if known, when listing the era names. localeRef false false Specify the name of a page, session, application, or request scope attribute of type java.util.Locale to use for locale. Generate an era select box ]]>