Taligent's Date and Time Formatting Demo Guide

Date and time formatters convert internal time data into text strings for meaningful display. The Taligent date and time formatters:

Localized Formatting and Parsing  Editing Format Patterns
Date Formatting Utilities

Localized Formatting and Parsing

The date and time formatters let you format the time according to the language, format, and time zone for a given country. The formatters also provide language-specific parsing.

The applet displays the date in two formats--the Java 1.0 representation ("1.0 Date") and the localized format generated by the Taligent date and time formatters ("1.1 Date").

To See This...

Do This...

Dates localized for the language and time zones of the selected locale.

  1. Pull down the Locale menu
  2. Try several different locales with the up and down arrow keys (on Windows) or the mouse button (on Macintosh)

The formatter can parse changes to the formatted Java 1.1 date and reflect it in the Java 1.0 date and the value in milliseconds.

  1. Select an English locale
  2. Replace the month name in the 1.1 Date field with "June"

The formatter formats correctly for different time zones within a country, for example, Pacific or Eastern time. It also switches automatically between standard time or daylight savings time based on the current date within the year.

  1. Select the U.S. locale
  2. Select the Time Format.
  3. Pull down the City menu and select different cities to see the time in different time zones

Note: The dates shown here are all based on the Gregorian calendar. The time formatting classes define an abstract calendar class that can be extended to support non-Gregorian calendars. This can be used by programmers, without special knowledge of which calendar is right for which country.

Editing Format Patterns

As with the number formatters, you can easily create and modify date and time formats by specifying string patterns. You can also add new fields to the format, and create formats used for business purposes in some countries.

To See This...

Do This...

The format pattern supports a variety of fields, and supports both full and abbreviated formats for some fields. The month, for example, can be numeric, abbreviated, or full.

  1. Select the Date Format and the English (U.S.) locale
  2. In the Pattern field, delete an "M"--the month changes to the abbreviated format
  3. Delete another "M"--the month changes to the numeric format

You can specify formats used in business documents, such as day of the year. You can also add unformatted strings to the pattern by enclosing them in single quotes.

  1. Select the month and day fields in the pattern ("MM dd")
  2. Replace it with the string (including the single quotes) "'day' D"

Date Formatting Utilities

The formatters also provide a number of utilities that you can use to build date and time widgets, including adding to or rolling fields.

To See This...

Do This...

"Rolling" a field prevents other fields from being affected by the change (where possible). In particular, when the maximum value is reached, the next value returns to the minimum. This works like resetting your digital clock.

  1. Select the Date Format and the English (U.S.) locale
  2. Select Month in the Date Fields menu
  3. Click on the Roll button
  4. Click the up-arrow button until the formatted date reaches December
  5. Click again--the month rolls to January but the year does not increment

"Adding" to a field causes other fields to be affected by the change as appropriate.

  1. Click on the Add button
  2. Click the up-arrow button until the formatted date reaches December
  3. Click again--the month rolls to January and the year does increment

Note that the formatter can handle a wide range of dates. (Note: Currently there is a bug that causes problems with dates before 1200 BC and after 5000 AD).

To See This...

Do This...

The formatted date changes to reflect changes in the millisecond value of the date.

  1. Select the Date Format and the English (U.S.) locale
  2. Type a "G" at the end of the pattern string to display the era
  3. Select the value in the Millis field and replace it with a "1"
  4. Add zeroes until you reach the year 5000 AD (you could also start at "-1" and add zeroes to go backwards in time)

The formatter supports many different fields you can use to create patterns. ASCII letters are reserved as pattern letters (unless enclosed in quotes), defined as the following:






era designator








month in year

(Text / Number)

July / 07


day in month




hour in day




hour in day, 0-based




minute in hour




second in minute








day in week




day in year




day of week in month


2 (2nd Wed in July)


week in year




week in month




am/pm marker




hour in am/pm




hour in am/pm, 0-based




time zone




escape for text




single quote



You can type in other dates in either date field or enter a completely new pattern to see different formatting behaviors. Try it out!

The source.

This page incorporates material or code copyrighted by Taligent, Inc. For more information on international resources, see their International Fact Sheet.