%dw 2.0
import * from dw::util::Coercions
output application/dw
---
{
a: toDateTimeOrNull("2003-10-01 23:57:59Z", [{format: "uuuu/MM/dd HH:mm:ssz"}, {format: "uuuu-MM-dd HH:mm:ssz"}]),
b: toDateTimeOrNull("2003-10-01 23:57:59Z", [{format: "uuuu/MM/dd HH:mm:ssz"}])
}
toDateTimeOrNull
toDateTimeOrNull(str: String, formatters: Array<Formatter>): DateTime | Null
Transforms a String
value into a DateTime
value using the first Formatter
that matches
with the given value to transform.
If none of the Formatter
matches with the given value, the function returns a null
value.
Introduced in DataWeave version 2.5.0.
Parameters
Name | Type | Description |
---|---|---|
|
String |
The |
|
Array<Formatter> |
The |
Example
This example shows how toDateTimeOrNull
behaves with different inputs.
It produces output in the application/dw
format.