%dw 2.0
import * from dw::util::Coercions
import * from dw::Runtime
output application/dw
---
{
a: toLocalDateTime("2003-10-01 23:57:59", [{format: "uuuu/MM/dd HH:mm:ss"}, {format: "uuuu-MM-dd HH:mm:ss"}]),
b: try(() -> toLocalDateTime("2003-10-01 23:57:59", [{format: "uuuu/MM/dd HH:mm:ss"}])).error.message
}
toLocalDateTime
toLocalDateTime(str: String, formatters: Array<Formatter>): LocalDateTime
Transforms a String
value into a LocalDateTime
value using the first Formatter
that
matches with the given value to transform.
Introduced in DataWeave version 2.5.0.
Parameters
Name | Type | Description |
---|---|---|
|
String |
The |
|
Array<Formatter> |
The |
Example
This example shows how toLocalDateTime
behaves with different inputs.
It produces output in the application/dw
format.
Source
toLocalDateTime(str: String, format: String | Null = null, locale: String | Null = null): LocalDateTime
Transforms a String
value into a LocalDateTime
value
and accepts a format and locale.
Introduced in DataWeave version 2.4.0.
Parameters
Name | Description |
---|---|
|
The |
|
The formatting to use on the |
|
Optional ISO 3166 country code to use, such as |
Example
This example shows how toLocalDateTime
behaves with different inputs.
It produces output in the application/dw
format.