Glenn Nielsen 1.0 1.1 datetime http://jakarta.apache.org/taglibs/datetime-1.0 Datetime Tag Library (Beta 1)

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.

/WEB-INF/datetime.tld dt This custom tag library requires no software other than a servlet container that supports the JavaServer Pages Specification, version 1.1 or higher.

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. 1.0 None 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. Formats a date in milliseconds since Jan 1, 1970 GMT for output as a date string. 1.0 The body of the tag must be a Date in milliseconds since Jan 1, 1970 GMT. pattern no no Date Time Pattern Format string to use for formatting the date. 1.0 patternId no no Name of a script variable which contains a Date Time Pattern Format string to use for formatting the date. 1.0 timeZone no no Name of a timeZone script id variable. Date formatting is adjusted for the time zone. 1.0 date no yes Set the date to format by passing in a Date object using a runtime expression value. 1.0 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. 1.0 locale no no Set to "true" to use the clients locale, if known, when formatting date. 1.0 Display the current time formatted ]]> 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. 1.0 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. 1.0 patternId no no Name of a script variable which contains a Date Time Pattern Format string to use when parsing the date. 1.0 timeZone no no Name of a timeZone script id variable. The date is adjusted for the time zone. 1.0 locale no no Set to "true" to use the clients locale, if known, when formatting date. 1.0 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. 1.0 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. 1.0 id true false Script variable id of the time zone for use with the parse and format tags. 1.0 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. 1.0 None id org.apache.taglibs.datetime.TimeZonesTag true NESTED TimeZones Bean 1.0 zoneId Yes No Returns the current time zone ID. 1.0 displayName Yes No Returns the current time zone display name. 1.0 id true false Script variable id for use with standard jsp:getProperty tag. 1.0 locale false false Set to "true" to use the clients locale, if known, when formatting time zone display names. 1.0 style false false Style of display name, either "SHORT" or "LONG". 1.0 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. 1.0 None id org.apache.taglibs.datetime.MonthsTag true NESTED Months of the year Bean 1.0 monthOfYear Yes No Returns the number of the month of the year. 1.0 month Yes No Returns the full name of the month of the year. 1.0 shortMonth Yes No Returns the short name of the month of the year. 1.0 id true false Script variable id for use with standard jsp:getProperty tag. 1.0 locale false false Set to "true" to use the clients locale, if known, when listing the month names. 1.0 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. 1.0 None id org.apache.taglibs.datetime.WeekdaysTag true NESTED Days of the week Bean 1.0 dayOfWeek Yes No Returns the number of the day of the week. 1.0 weekday Yes No Returns the full name of the day of the week. 1.0 shortWeekday Yes No Returns the short name of the day of the week. 1.0 id true false Script variable id for use with standard jsp:getProperty tag. 1.0 locale false false Set to "true" to use the clients locale, if known, when listing the week day names. 1.0 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. 1.0 None id org.apache.taglibs.datetime.AmPmsTag true NESTED Am/Pm names Bean 1.0 name Yes No Returns the am/pm name. 1.0 id true false Script variable id for use with standard jsp:getProperty tag. 1.0 locale false false Set to "true" to use the clients locale, if known, when listing the am/pm names. 1.0 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. 1.0 None id org.apache.taglibs.datetime.ErasTag true NESTED Era names Bean 1.0 name Yes No Returns the era name. 1.0 id true false Script variable id for use with standard jsp:getProperty tag. 1.0 locale false false Set to "true" to use the clients locale, if known, when listing the era names. 1.0 Generate an era select box ]]>
First Beta Release Clean up of tag library prior to performing a beta release, moving toward an official release.
Changed the name of the currentime tag to currentTime. Changed the name of the timeZone tag to timeZone. Changed the name of the timezones tag to timeZones. Changed the name of the ampms tag to amPms. Changed the name of the parse tag timezone attribute to timeZone. Changed the name of the format tag timezone attribute to timeZone. Added the patternId attribute to the format and parse tags.
Implementation of some requested changes.
Added date and default attributes to the format tag.
The format tag now ignores any white space in its tag body.
Initial version of tag library before Jakarta-Taglibs had an official release policy for tag libraries.