---
schema_version: "1"
id: d7be8a200d4fedf6cbb485f6284390a264f04921bced2283e6bebb7512c1897e
title: toLocalDateTime
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.4/dw-coercions-functions-tolocaldatetime.md
canonical_url: https://docs.mulesoft.com/dataweave/2.4/dw-coercions-functions-tolocaldatetime
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 1baa9524ad743ee8db97dae02523131036ab69548a691ae844177cbfd7d97aab
description: MuleSoft Documentation Site
release: "2.4"
latest: false
---
---
product: DataWeave
version: 2.4
---

# toLocalDateTime

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

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

<table><colgroup><col> <col></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><p><code>str</code></p></td><td><p>The <code>String</code> value to transform into a <code>LocalDateTime</code> value.</p></td></tr><tr><td><p><code>format</code></p></td><td><p>The formatting to use on the <code>LocalDateTime</code> value. A <code>null</code> value has no effect on the <code>LocalDateTime</code> value. This parameter accepts Java character patterns based on ISO-8601. A <code>LocalDateTime</code> value, such as <code>2011-12-03T10:15:30.000000</code> has the format <code>uuuu-MM-dd HH:mm:ss</code>.</p></td></tr><tr><td><p><code>locale</code></p></td><td><p>Optional ISO 3166 country code to use, such as <code>US</code>, <code>AR</code>, or <code>ES</code>. A <code>null</code> or absent value uses your JVM default.</p></td></tr></tbody></table>

### Example

This example shows how `toLocalDateTime` 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: toLocalDateTime("2015-10-01T23:57:59"),
  b: toLocalDateTime("2003-10-01 23:57:59","uuuu-MM-dd HH:mm:ss")
}
```

#### Output

```DataWeave
{
  a: |2015-10-01T23:57:59|,
  b: |2003-10-01T23:57:59| as LocalDateTime {format: "uuuu-MM-dd HH:mm:ss"}
}
```
