---
title: "Formatting Fields"
canonical: "https://docs.getxray.app/space/XRAYCLOUD/44570592/Formatting%20Fields"
format: markdown
---
<details>
<summary>Table of Contents</summary>

> Macro (toc)
</details>

# Formatting Date Fields

If you are exporting a date field such as *CreatedDate* and *LastUpdateDate*, you can define how the date is displayed. All the patterns supported by the [DateTimeFormatter](https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html) Java API are supported.

**Definition: **`${dateformat("<Format>"):<Field name>}`

##### **Sample Code**

```
${dateformat("yyyy-MM-dd"):Created}
${dateformat("EEE, MMM d, ''yy"):Created}
${dateformat("EEE, d MMM yyyy HH:mm:ss Z"):Updated}
```

# Formatting Number Field

If you are exporting a Number Field, you can define how the number is displayed. All the patterns supported by the [DecimalFormat(String pattern)](http://docs.oracle.com/javase/7/docs/api/java/text/DecimalFormat.html#DecimalFormat(java.lang.String)) Java API are supported.

You can also specify the Locale you want to use. All the Locales in [JRE 7 Supported Locales](http://www.oracle.com/technetwork/java/javase/javase7locales-334809.html) page are supported.

**Definition: **

`${numberformat(` `"<pattern>"` `):<Field name>}`

`${numberformat(` `"<Locale>"` `,` `"<pattern>"` `):<Field name>} `

##### **Sample Code (considering Price as a custom Number Field)**

```
${numberformat("###,###.###"):Price}
${numberformat("\u20AC ###,###.###"):Price}
${numberformat("de_DE" , "###,###.###"):Price}
${numberformat("##0.#####E0"):Price}
${numberformat("en_UK" , "#0.#####%"):Price}
```

# Formatting User Picker Fields<span style="color: #4a6785"> </span>

If you are exporting a *User Picker* or *Multiple Users* custom field, you can output the Display Name using the **fullname** function.

**Definition: **`${fullname:<Field name>}`

##### **Sample Code**

```
${fullname:UserCustomField}
```

If you are exporting a *User Picker* or *Multiple Users* custom field, you can output the email using the **emailaddress** function.

**Definition: **`${emailaddress:<Field name>}`

##### **Sample Code**

```
${emailaddress:UserCustomField}
```

# Escaping Fields

<span style="color: #333333">This function allows fields with line breaks or other special characters to be used inside JavaScript.</span>

**Definition: **`${escape:<Field name>}`

##### **Sample Code**

```
${escape:Description}
${escape:Custom Field}
 
%{('${escape:Description}'.length > 0) ? 'This issue has description': 'This issue does not have description'
```

# <span style="color: #000000">Creating Mappings Based on JavaScript Using Formatted Fields</span>

There are times when it may be needed to format a field, execute JavaScript actions on the formatted field, and export the result as HTML.  
In these cases, all the above formats are available.

##### **Sample Code**

```
${html:%{'${escape:Description}'.replace(new RegExp('toReplace','g'),'replacer')}}
```

# Formatting Duration Time Field

If you are exporting a duration time field, you can define the behavior you want to get the correspondent value.

Let's suppose you want to export the duration of an Issue: you can get this value in milliseconds, as well as the formatted version of this value.

Furthermore, this field allows you to execute JavaScript action on the duration time field and export the result.  
 

**Definition: **`${durationformat:<Field name>}`

##### **Sample Code**

```
${durationformat:Custom Field}

${durationformat:%{var timeValue="<Value>"; timeValue;}}
```


<details>
<summary>Support/Troubleshooting</summary>

If you have questions or technical issues, please [contact the Support team via the Customer Portal (Jira service management)](https://jira.getxray.app/servicedesk/customer/portal/2/user/login?destination=portal%2F2%2Fcreate%2F28) or [send us a message using the in-app chat](https://getxraydocs.atlassian.net/wiki/spaces/XRAYCLOUD/pages/44577312).
</details>