%dw 2.0
import * from dw::util::Coercions
import * from dw::Runtime
output application/dw
---
{
a: toTime("13:44:12.283-08:00", [{format: "HH:mm:ss.xxx"}, {format: "HH:mm:ss.nxxx"}]),
b: try(() -> toTime("13:44:12.283-08:00", [{format: "HH:mm:ss.xxx"}]).error.message
}
toTime
toTime(str: String, formatters: Array<Formatter>): Time
Transforms a String
value into a Time
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 toTime
behaves with different inputs.
It produces output in the application/dw
format.
toTime(str: String, format: String | Null = null, locale: String | Null = null): Time
Transforms a String
value into a Time
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 |