The Number value to format.
toString
toString(number: Number, format: String | Null = null, locale: String | Null = null, roundMode: RoundingMode | Null = null): String
A variant of toString that transforms a Number value
(whole or decimal) into a String value and accepts a
format, locale, and rounding mode value.
Introduced in DataWeave version 2.4.0.
Parameters
| Name | Description | 
|---|---|
| 
 | |
| 
 | The formatting to apply to the  | 
| 
 | Optional ISO 3166 country code to use, such as  | 
| 
 | Optional parameter for rounding decimal values
              when the formatting presents a rounding choice,
              such as a format of  
 | 
Example
This example shows how toString behaves with different inputs.
toString(date: Date | DateTime | LocalDateTime | LocalTime | Time, format: String | Null = null, locale: String | Null = null): String
A variant of toString that transforms a Date, DateTime,
LocalTime, LocalDateTime, or Time value into a String value.
Introduced in DataWeave version 2.4.0.
Parameters
| Name | Description | 
|---|---|
| 
 | The  | 
| 
 | The ISO-8601 formatting to use on the date or time.
           For example, this parameter accepts character patterns
           based on the Java 8  
 | 
| 
 | Optional ISO 3166 country code to use, such as  | 
Example
This example shows how toString behaves with different inputs.
Source
%dw 2.0
import * from dw::util::Coercions
output application/json
---
{
   aDate: toString(|2003-10-01|, "uuuu/MM/dd"),
   aDateTime: toString(|2018-09-17T22:13:00-03:00|),
   aLocalTime: toString(|23:57:59|, "HH-mm-ss"),
   aLocalDateTime : toString(|2015-10-01T23:57:59|),
   aLocalDateTimeFormatted: toString(|2003-10-01T23:57:59|, "uuuu-MM-dd HH:mm:ss a"),
   aLocalDateTimeFormattedAndLocalizedSpain: toString(|2003-01-01T23:57:59|, "eeee, dd MMMM, uuuu HH:mm:ss a", "ES"),
   aTime: typeOf(|22:10:18Z|),
   aTimeZone: toString(|-03:00|)
}Output
{
  "aDate": "2003/10/01",
  "aDateTime": "2018-09-17T22:13:00-03:00",
  "aLocalTime": "23-57-59",
  "aLocalDateTime": "2015-10-01T23:57:59",
  "aLocalDateTimeFormatted": "2003-10-01 23:57:59 PM",
  "aLocalDateTimeFormattedAndLocalizedSpain": "miƩrcoles, 01 enero, 2003 23:57:59 p. m.",
  "aTime": "Time",
  "aTimeZone": "-03:00"
}toString(binary: Binary, encoding: String): String
A variant of toString that transforms a Binary value
into a String value with the specified encoding.
Introduced in DataWeave version 2.4.0.
Parameters
| Name | Description | 
|---|---|
| 
 | The  | 
| 
 | The encoding to apply to the  | 
toString(data: TimeZone | Uri | Boolean | Period | Regex | Key): String
A variant of toString that transforms a TimeZone, Uri,
Boolean, Period, Regex, or Key value into a
string.
Introduced in DataWeave version 2.4.0.
Parameters
| Name | Description | 
|---|---|
| 
 | The  | 
Example
This example shows how toString behaves with different inputs.
Source
%dw 2.0
import * from dw::util::Coercions
output application/json
---
{
  transformTimeZone: toString(|Z|),
  transformBoolean: toString(true),
  transformPeriod: toString(|P1D|),
  transformRegex: toString(/a-Z/),
  transformPeriod: toString(|PT8M10S|),
  transformUri: toString("https://docs.mulesoft.com/" as Uri)
}  ++
{ transformKey : toString((keysOf({ "aKeyToString" : "aValue"})[0])) }


