---
schema_version: "1"
id: 26c8654667d4e286601729e16d6b650e0a20d08662554fc64ea565029abfe445
title: toLocalTimeOrNull
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.6/dw-coercions-functions-tolocaltimeornull.md
canonical_url: https://docs.mulesoft.com/dataweave/2.6/dw-coercions-functions-tolocaltimeornull
source_site: docs.mulesoft.com
content_type: documentation
content_hash: c4cf38d62a84e4bfc3a4e618507c4eb98692a04c5a1f7c8c552f80d4e0627c1d
description: MuleSoft Documentation Site
release: "2.6"
latest: false
---
---
product: DataWeave
version: 2.6
---

# toLocalTimeOrNull

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

## toLocalTimeOrNull(str: String, formatters: Array<Formatter>): LocalTime | Null

Transforms a `String` value into a `LocalTime` 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

<table><colgroup><col> <col> <col></colgroup><thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><p><code>str</code></p></td><td><p>String</p></td><td><p>The <code>String</code> value to transform into a <code>LocalTime</code> value.</p></td></tr><tr><td><p><code>formatters</code></p></td><td><p>Array&lt;Formatter&gt;</p></td><td><p>The <code>array</code> of formatting to use on the <code>LocalTime</code> value.</p></td></tr></tbody></table>

### Example

This example shows how `toLocalTimeOrNull` behaves with different inputs. It produces output in the
`application/dw` format.

#### Source

```DataWeave
%dw 2.0
import * from dw::util::Coercions
output application/dw
---
{
  a: toLocalTimeOrNull("23:57:59", [{format: "HH:mm:ss.n"}, {format: "HH:mm:ss"}]),
  b: toLocalTimeOrNull("23:57:59", [{format: "HH:mm:ss.n"}])
}
```

#### Output

```DataWeave
{
  a: |23:57:59| as LocalTime {format: "HH:mm:ss"},
  b: null
}
```
