Format date as string

Supported in: Batch, Streaming

Returns the date as formatted string in accordance to the Java DateTimeFormatter. The default format is ISO8601.

Expression categories: Cast, String

Declared arguments

  • Date - The date to format as a string.
    Expression<Date>
  • optional Format - The format to use. The default format is ISO8601.
    Literal<String>

Output type: String

Examples

Example 1: Base case

Argument values:

  • Date: 2022-12-20
  • Format: yy-MM-dd

Output: 22-12-20


Example 2: Base case

Argument values:

  • Date: 2022-12-20
  • Format: null

Output: 2022-12-20


Example 3: Null case

Argument values:

  • Date: null
  • Format: yyyy-MM-dd

Output: null


Example 4: Edge case

Argument values:

  • Date: 2022-12-20
  • Format: E

Output: Tue


Example 5: Edge case

Argument values:

  • Date: 2022-12-20
  • Format: EEEE

Output: Tuesday