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

# toDate

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

## toDate(str: String, format: String | Null = null, locale: String | Null = null): Date

Transforms a `String` value into a `Date` 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>Date</code> value.</p></td></tr><tr><td><p><code>format</code></p></td><td><p>The formatting to use on the <code>Date</code> value. A <code>null</code> value has no effect on the <code>Date</code> value. This parameter accepts Java character patterns based on ISO-8601. A <code>Date</code> value, such as <code>2011-12-03</code>, has the format <code>uuuu-MM-dd</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 `toDate` 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: toDate("2015-10-01"),
  b: toDate("2003/10/01","uuuu/MM/dd")
}
```

#### Output

```DataWeave
{
  a: |2015-10-01|,
  b: |2003-10-01| as Date {format: "uuuu/MM/dd"}
}
```
