toLocalTime

toLocalTime(str: String, format: String | Null = null, locale: String | Null = null): LocalTime

Transforms a String value into a LocalTime value and accepts a format and locale.

Introduced in DataWeave version 2.4.0.

Parameters

Name Description

str

The String value to transform into a LocalTime value.

format

The formatting to use on the LocalTime value. A null value has no effect on the LocalTime value. This parameter accepts Java character patterns based on ISO-8601. A LocalTime value, such as 22:15:30.000000, has the format HH:mm:ss.n.

locale

Optional ISO 3166 country code to use, such as US, AR, or ES. A null or absent value uses your JVM default.

Example

This example shows how toLocalTime behaves with different inputs.

Source

%dw 2.0
import * from dw::util::Coercions
output application/json
---
{
   toLocalTimeEx: toLocalTime("23:57:59"),
   toLocalTimeEx2: toLocalTime("13:44:12.283","HH:mm:ss.n")
}

Output

{
  "toLocalTimeEx": "23:57:59",
  "toLocalTimeEx2": "13:44:12.283"
}

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub