Format Date directive
The FORMAT-DATE directive formats CDAP timestamp_micros values to custom pattern strings.
To convert strings to timestamp_micros values, see PARSE-AS-SIMPLE-DATE.
To convert timestamp columns to date columns, see Converting Timestamp types to Date.
Syntax
format-date :column 'format'
Usage Notes
Date and time formats are specified by date and time 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. Text can be quoted using single quotes ('
) to avoid interpretation. Two single quotes ''
represents a single quote. All other characters are not interpreted; they're simply copied into the output string during formatting or matched against the input string during parsing.
Supported Patterns for Formatting and Parsing
CDAP supports the Java SimpleDateFormat patterns for formatting and parsing datetime values. For more information about the SimpleDateFormat patterns, see the SimpleDateFormat documentation.
Date and Time Pattern Examples
Prior to using these patterns, the directive PARSE-AS-SIMPLEDATE must be applied to correctly create a complete timestamp_micros value.
These examples show how date and time patterns are interpreted in the U.S. locale. If the given date and time is 2001-07-04 12:08:56
, and is a local time in the U.S. Pacific Time Zone, then applying different patterns results in these strings:
Date and Time Pattern | Date String |
---|---|
| 2001.07.04 AD at 12:08:56 PDT |
| Wed, Jul 4, '01 |
| 12:08 PM |
| 12 o'clock PM, Pacific Daylight Time |
| 0:08 PM, PDT |
| 2001.July.04 AD 12:08 PM |
| Wed, 4 Jul 2001 12:08:56 -0700 |
| 010704120856-0700 |
| 2001-07-04T12:08:56.235-0700 |
| 2001-07-04T12:08:56.235-07:00 |
| 07/04/2001 12:09 |
| 2001-07-04 |
| 1/2/09 6:17 |
Created in 2020 by Google Inc.