format
Converts a Date to a String in the given format.
The first argument to this function must be a Date or a Number, and the second argument must be a format String that follows the Java SimpleDateFormat.
For example, given a schema such as:
{ "type": "record", "name": "events", "fields": [ { "name": "name", "type": "string" }, { "name": "eventDate", "type" : { "type" : "long", "logicalType" : "timestamp-millis" } } ] }
and a record such as:
{ "name" : "My Event", "eventDate" : 1508457600000 }
The following record path expressions would format the date as a String:
RecordPath |
Return value |
|
2017-10-20'T'11:00:00'Z' |
|
2017-10-20 |
In the case where the field is declared as a String, the toDate function must be called before formatting.
For example, given a schema such as:
{ "type": "record", "name": "events", "fields": [ { "name": "name", "type": "string" }, { "name": "eventDate", "type" : "string"} ] }
and a record such as:
{ "name" : "My Event", "eventDate" : "2017-10-20'T'11:00:00'Z'" }
The following record path expression would re-format the date String:
RecordPath |
Return value |
|
2017-10-20 |