<DateFormat> and <TimeFormat> elements of a localization file

You can specify any of the following attribute values for the DateFormat and TimeFormat elements:

  • short
  • medium
  • long

For example (for the en_US locale):

<DateFormat short="MM/dd/yyyy"
            medium="MMM d, yyyy"
            long="E, MMM d, yyyy" />

 <TimeFormat short="hh:mm aa"
            medium="hh:mm aa"
            long="hh:mm aa"/>
In general, you can use any of the date and time patterns supported by the Java class SimpleDateFormat for the medium and long formats. However, Guidewire maps the short format to the date picker widget, which does not support arbitrary date formats. For a description of these patterns, refer to the following web sites:

PolicyCenter uses the short form to recognize dates entered by the user. It uses the other forms to display dates and times.

Using the Short format

Define patterns for the short date and time definitions that result only in a fixed-length output that matches the pattern length.

Note: Time and date inputs in PCF files do not accept variable length format patterns, such as MMM. Therefore, for these fields, use only format patterns that result in fixed-length output. If you do use a variable-length input pattern, it is coerced during input into the short form.

In general, dates have three components, year, month, and day, each defined by a specific pattern. Each pattern provides a fixed-width output. For example, the following patterns all provide a fixed-width output. In this case, each output contains the same number of characters as the format pattern.

Format

Pattern

Output

year

yyyy

4 digit output, fixed

month

MM

2 digit output, fixed

day

dd

2 digit output, fixed

A pattern that does not work

The following list describes an incorrect, non-fixed-width pattern:

Format

Pattern

Output

year

yyyy

4 digit output, fixed

month

MMM

variable length output

day

dd

2 digit output, fixed

The pattern MMM does not work as there are languages in which the abbreviated month string is not three characters in length. Attempting to use this pattern with a language in which there are abbreviated month strings that are not three characters in length can cause a validation error.