---
schema_version: "1"
id: fc8c6ed074da4a6d117ecc28c9acc3dd834cd3ff58aab192b80a81d67a724304
title: Coercions (dw::util::Coercions)
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.4/dw-coercions.md
canonical_url: https://docs.mulesoft.com/dataweave/2.4/dw-coercions
source_site: docs.mulesoft.com
content_type: documentation
content_hash: fb3d0cf60416cadab59c85ef1c35d066690ac1bcac8804d50099370f742264b6
description: MuleSoft Documentation Site
release: "2.4"
latest: false
---
---
product: DataWeave
version: 2.4
---

# Coercions (dw::util::Coercions)

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

This utility module assists with type coercions.

To use this module, you must import it to your DataWeave code, for example, by adding the line
`import * from dw::util::Coercions` to the header of your DataWeave script.

_Introduced in DataWeave version 2.4.0._

## Functions

<table><colgroup><col> <col></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><p><a href="https://docs.mulesoft.com/dataweave/2.4/dw-coercions-functions-toarray">toArray</a></p></td><td><p>Splits a <code>String</code> value into an <code>Array</code> of characters.</p></td></tr><tr><td><p><a href="https://docs.mulesoft.com/dataweave/2.4/dw-coercions-functions-tobinary">toBinary</a></p></td><td><p>Transform a <code>String</code> value into a <code>Binary</code> value using the specified encoding.</p></td></tr><tr><td><p><a href="https://docs.mulesoft.com/dataweave/2.4/dw-coercions-functions-toboolean">toBoolean</a></p></td><td><p>Transform a <code>String</code> value into a <code>Boolean</code> value.</p></td></tr><tr><td><p><a href="https://docs.mulesoft.com/dataweave/2.4/dw-coercions-functions-todate">toDate</a></p></td><td><p>Transforms a <code>String</code> value into a <code>Date</code> value and accepts a format and locale.</p></td></tr><tr><td><p><a href="https://docs.mulesoft.com/dataweave/2.4/dw-coercions-functions-todatetime">toDateTime</a></p></td><td><p>Transforms a <code>Number</code> value into a <code>DateTime</code> value using <code>milliseconds</code> or <code>seconds</code> as the unit.</p></td></tr><tr><td><p><a href="https://docs.mulesoft.com/dataweave/2.4/dw-coercions-functions-tolocaldatetime">toLocalDateTime</a></p></td><td><p>Transforms a <code>String</code> value into a <code>LocalDateTime</code> value and accepts a format and locale.</p></td></tr><tr><td><p><a href="https://docs.mulesoft.com/dataweave/2.4/dw-coercions-functions-tolocaltime">toLocalTime</a></p></td><td><p>Transforms a <code>String</code> value into a <code>LocalTime</code> value and accepts a format and locale.</p></td></tr><tr><td><p><a href="https://docs.mulesoft.com/dataweave/2.4/dw-coercions-functions-tonumber">toNumber</a></p></td><td><p>A variant of <code>toNumber</code> that transforms a <code>DateTime</code> value into a number of seconds or milliseconds, depending on the selected unit.</p></td></tr><tr><td><p><a href="https://docs.mulesoft.com/dataweave/2.4/dw-coercions-functions-toperiod">toPeriod</a></p></td><td><p>Transform a <code>String</code> value into a <code>Period</code> value.</p></td></tr><tr><td><p><a href="https://docs.mulesoft.com/dataweave/2.4/dw-coercions-functions-toregex">toRegex</a></p></td><td><p>Transforms a <code>String</code> value into a <code>Regex</code> value.</p></td></tr><tr><td><p><a href="https://docs.mulesoft.com/dataweave/2.4/dw-coercions-functions-tostring">toString</a></p></td><td><p>A variant of <code>toString</code> that transforms a <code>Number</code> value (whole or decimal) into a <code>String</code> value and accepts a format, locale, and rounding mode value.</p></td></tr><tr><td><p><a href="https://docs.mulesoft.com/dataweave/2.4/dw-coercions-functions-totime">toTime</a></p></td><td><p>Transforms a <code>String</code> value into a <code>Time</code> value and accepts a format and locale.</p></td></tr><tr><td><p><a href="https://docs.mulesoft.com/dataweave/2.4/dw-coercions-functions-totimezone">toTimeZone</a></p></td><td><p>Transform a <code>String</code> value into a <code>TimeZone</code> value.</p></td></tr><tr><td><p><a href="https://docs.mulesoft.com/dataweave/2.4/dw-coercions-functions-touri">toUri</a></p></td><td><p>Transforms a <code>String</code> value into a <code>Uri</code> value.</p></td></tr></tbody></table>

## Types

- [Coercions Types](https://docs.mulesoft.com/dataweave/2.4/dw-coercions-types)
