Skip to main content

Temporal templates

The functions Timestamp.Parse, Date.Parse and Time.Parse will parse the corresponding type from a string using a template.

For example:

Timestamp.Parse("2018-02-01 01:02","yyyy-MM-dd H:m")

Date and time templates are specified by letters representing the components of a date or time.

The following patterns are supported:

dday of month
Dday of year
Mmonth of year (7, 07, Jul, July)
yyear
Yweek based year, see java doc for more info.
wweek of week based year (1-53)
eday of week (2, Tue, Tuesday)
Hhour of day (0-23)
Khour of day (0-11)
mminute of hour
ssecond of minute
Sfraction of second
aam or pm
'escape for text (‘foo’, ‘bar’)

When repeated, these characters indicate a minimum number of characters the string should match.

  • MMM parses short month names (Jan, Feb) and MMMM parses full month names (January, February).

  • yy parses as the last two digits of a year with a base year of 2000 (18 parses as 2018, 95 parses as 2095).

  • e parses day of week (1-7), eee parses short week day names (Mon, Tue) and eeee parses full week day names (Monday, Tuesday).

Note

Raw follows java conventions for date templates see java documentation for more info.

Examples