LISTSERV Maestro 8.1-4 Help

Forward >> << Back Table Of Contents

Calculation Formulas

Back to Calculation Formulas Overview
Back to Functions Overview


Date/Time Patterns

This sub-section describes the format of the date/time patterns that must be specified for the functions "ToDateText" and "ToMillis" to convert a numerical date/time value (represented in milliseconds since "Jan. 1st 1970, 00:00:00 GMT") into a formatted output string, or vice versa.

The pattern format described in this section applies both to the formatting process, when a numerical date/time value is converted into a formatted text string, as well as to the parsing process, when a text string is parsed to convert it back into the numerical date/time value.

Note: This is a direct representation of the formatting offered by the Java class SimpleDateFormat, so the description of the format as given here has been taken more or less directly from the documentation of that Java class.

Important Note: For date/time formatting and parsing, by default, the U.S. locale is used. This means that if locale specific values (like names of months, weekdays, era-designators, and so on) are required, they will, by default, be given (or expected) as the U.S. locale values. If you do not want to use the default U.S. locale, you need to specify a locale in the relevant function.
Similarly with timezones: The formatting function "ToDateText" requires you to supply a timezone as an argument. But the parsing function "ToMillis" will, by default, interpret the given date/time text as relative to the time zone of the server, unless the text also contains timezone information (and the format pattern specifies this).


Date and Time Patterns

Date and time formats are specified by pattern strings. Within pattern strings, unquoted letters from 'A' to 'Z' and from 'a' to 'z' are interpreted as pattern letters representing the components of a date or time string (see below for details). Text can be quoted using single quotes (') to avoid interpretation. In a quoted text, the "double" single quote ('') represents a single quote. All other characters are not interpreted; they are simply copied into the output string during formatting or matched against the input string during parsing.

The following pattern letters are defined (all other characters from 'A' to 'Z' and from 'a' to 'z' are reserved).

Note: the letters are case-sensitive, so the same letter has different meanings in its uppercase or lowercase version. Each pattern letter has a specific "presentation" in the created final string (during formatting) or in the parsed string (during parsing). For example, presentation types may be "Text", "Number", "Year" and so on. More details about the presentations and their meanings follow below.

Commonly Used Pattern Letters:

LetterDate or Time ComponentPresentationExamples
yYearYear1996; 96
MMonth in yearMonthJuly; Jul; 07
dDay in monthNumber10
EWeekdayTextTuesday; Tue
HHour in day (0-23)Number0
hHour in am/pm (1-12)Number12
mMinute in hourNumber30
sSecond in minuteNumber55
SMillisecondNumber978
aAm/pm markerTextPM

Special Pattern Letters:

LetterDate or Time ComponentPresentationExamples
GEra designatorTextAD; BC
DDay in yearNumber189
wCalendar week in yearNumber27
WCalendar week in monthNumber2
FWeekday ordinal in monthNumber3
kHour in day (1-24)Number24
KHour in am/pm (0-11)Number0
zTime zoneGeneral time zonePacific Standard Time; PST;GMT-08:00
ZTime zoneRFC 822 time zone-0800

Note: The value of "calendar week in year" and "calendar week in month" depends on the locale where it is used, on the conventions in the given locale about which weekday is interpreted as the first day of the week (usually either "Monday" or "Sunday"), and under what circumstances a week that falls partially into one year (or month) and partially into the next is interpreted as belonging to the one year (or month) or the other.

Note: The "weekday ordinal in month" indicates the ordinal number of the weekday of the given date/time in the given month. So, for the first Monday in a month, the ordinal is "1", as it is for the first Tuesday, Wednesday and so on. For the second Monday in a month the ordinal is "2", etc.

Presentation Description

Pattern letters are usually repeated, as their number determines the exact presentation:

Examples

The following examples show how date and time patterns are interpreted in the default U.S. locale with the "U.S. Pacific Time" time zone. The given date and time are "2001-07-04 12:08:56" local time in that time zone.

Date and Time PatternResult
"yyyy.MM.dd G 'at' HH:mm:ss z"2001.07.04 AD at 12:08:56 PDT
"EEE, MMM d, ''yy"Wed, Jul 4, '01
"h:mm a"12:08 PM
"hh 'o''clock' a, zzzz"12 o'clock PM, Pacific Daylight Time
"K:mm a, z"0:08 PM, PDT
"yyyyy.MMMMM.dd GGG hh:mm aaa"02001.July.04 AD 12:08 PM
"EEE, d MMM yyyy HH:mm:ss Z"Wed, 4 Jul 2001, 12:08:56 -0800
"yyMMddHHmmssZ"010704120856-0800

Predefined Locales

When specifying a locale to be used for date/time formatting in "ToDateText" or for parsing in "ToMillis", you can either specify the specific ISO codes of the desired country and language (see the description of "ToDateText" and "ToMillis), or you can simply specify one of the following predefined locale names, which stands as a shortcut for the given language and country combination:

Locale NameLanguageCountry
CANADAEnglish (en)Canada (CA)
CANADA_FRENCHFrench (fr)Canada (CA)
CHINAChinese (zh)China (CN)
FRANCEFrench (fr)France (FR)
GERMANYGerman (de)Germany (DE)
ITALYItalian (it)Italy (IT)
JAPANJapanese (jp)Japan (JP)
KOREAKorean (ko)Korea (KR)
SPAINSpanish (es)Spain (ES)
SWEDENSwedish (sv)Sweden (SE)
TAIWANChinese (zh)Taiwan (TW)
UKEnglish (en)Great Britain (GB)
USEnglish (en)USA (US)

© 2002-2017 L-Soft Sweden AB. All rights reserved.