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

# 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
}
```
