Parse and Format Date Function Calls

Last modified: March 1, 2024

1 Introduction

This document describes functions that are used to parse Date and time values from strings using a specified pattern, or to produce a string from a Date and time value.

For details on all pattern possibilities, see Class SimpleDateFormat.

2 parseDateTime[UTC]

Takes a string and parses it. If it fails and a default value is specified, it returns the default value. Otherwise, an error occurs. The function parseDateTime uses the user’s time zone and parseDateTimeUTC uses the UTC calendar.

2.1 Input Parameters

The input parameters are described in the table below:

Value Type
Date A string which contains the textual representation of a date, meaning, dd/mm/yyyy , mm/dd/yyyy, etc.
Format String
Default value (optional) Date and time

2.2 Output

The output is described in the table below:

Value Type
The parsed date or the default value if a date could not be parsed. Date and time

2.3 Example

The examples below illustrate which value the expression returns:

  • If you use the following input:

    1
    
    parseDateTime('2015-05-21', 'yyyy-MM-dd')
    

    the output is:

    1
    
    The date May 21, 2015\. The time will be 12 o'clock at night  because it is not specified.
    
  • If you use the following input:

    1
    
    parseDateTime('noDateTime', 'dd-MM-yyyy', dateTime(2007))
    

    the output is:

    1
    
    'Mon Jan 01 00:00:00 CET 2007'
    

3 formatDateTime[UTC]

Converts the Date and time value to a string, formatted according to the format parameter. Without the format parameter, a standard format is used, which depends on the Java version and user locale. The function formatDateTime uses the users calendar and formatDateTimeUTC uses the UTC calendar.

3.1 Input Parameters

The input parameters are described in the table below:

Value Type
Date Date and time
Format (optional) String

3.2 Output

The output is described in the table below:

Value Type
A formatted representation of the Date and time value. String

3.4 Example

If you use the following input:

1
formatDateTime($object/Date1,'EEE, d MMM yyyy HH:mm:ss Z')

the output is:

1
'Sun, 8 Jun 2008 10:12:01 +0200'

To get ‘1987-12-31T23:59:00’, you need to concatenate two formatDateTime[UTC] functions:

1
formatDateTime($object/Date1,'yyyy-MM-dd') + 'T' + formatDateTime($object/Date1,'HH:mm:ss')

4 formatTime[UTC]

Converts the time part of Date and time value to a string in a standard format, which depends on the Java version and user locale. formatTime uses the users calendar and formatTimeUTC uses the UTC calendar.

4.1 Input Parameters

The input parameters are described in the table below:

Value Type
Date Date and time

4.2 Output

The output is described in the table below:

Value Type
A formatted representation of the time part of the Date and time value. String

4.3 Example

If you use the following input:

1
formatTime(dateTime(1974, 7, 2, 9, 50, 10))

the output is:

1
'9:50 AM'

5 formatDate[UTC]

Converts the date part of Date and time value to a string in a standard format, which depends on the Java version and user locale. formatDate uses the users calendar and formatDateUTC uses the UTC calendar.

5.1 Input Parameters

The input parameters are described in the table below:

Value Type
Date Date and time

5.2 Output

The output is described in the table below:

Value Type
A formatted representation of the date part of the Date and time value. String

5.3 Example

If you use the following input:

1
formatDate(dateTime(1974, 7, 2, 9, 50, 10))

the output is:

1
'7/2/74'

6 dateTimeToEpoch

Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT to the date.

6.1 Input Parameters

The input parameters are described in the table below:

Value Type
Date Date and time

6.2 Output

The output is described in the table below:

Value Type
The number of milliseconds since January 1, 1970, 00:00:00 GMT to the date. Integer/Long

6.3 Example

If you use the following input:

1
dateTimeToEpoch(dateTime(1974, 7, 2, 9, 50, 10))

The output is:

1
141990610000

7 epochToDateTime

Creates a Datetime that represents the specified number of milliseconds since January 1, 1970, 00:00:00 GMT.

7.1 Input Parameters

The input parameters are described in the table below:

Value Type
Epoch Integer/Long

7.2 Output

The output is described in the table below:

Value Type
A Datetime that represents the specified number of milliseconds since January 1, 1970, 00:00:00 GMT. Date and time

7.3 Example

If you use the following input:

1
epochToDateTime(141990610000)

The output is:

1
dateTime(1974, 7, 2, 9, 50, 10)