Timestamp functions

This page describes the additional set of predefined Jsonnet functions for the Data Transformer Script task available in Application Integration.

Before you begin

To use the following predefined functions, you must import the functions library in your script. Importing the functions library lets you use both the standard Jsonnet functions and the predefined Data Transformer functions.

Application Integration supports Jsonnet functions library v0.20.0. For information about the Jsonnet standard functions, see Jsonnet Standard Library.

Date Format

Syntax
        
dateFormat(timestamp, format_string, timezone, current_format)
      
Description Formats a timestamp according to the specified format_string.
Input parameter timestamp: The input timestamp.

format_string: The new timestamp format. See Supported timestamp format elements for a list of format elements that can be used to form the new timestamp format string.

timezone: The timezone of the provided input timestamp. Default value is UTC.

current_format: The format which would be used to parse the provided input timestamp. Default value is E (epoch).

Return type STRING
Output Returns a new string after converting the input timestamp based on the specified format_string.

Supported timestamp format elements

The following table lists the supported format elements for the dateFormat() function:

Format element Description Example
YYYY 4-digit year. 2023
YY Last 2 digits of the year. 23
MMMM Name of the month in titlecase. March
MMM Abbreviated name of the month in titlecase. Mar
MM Month from 01 to 12. 03
M Month from 1 to 12. 3
DDDD Name of the day in titlecase. Monday
DDD Abbreviated name of the day. Mon
DD Day from 01 to 31. 06
D Day from 1 to 31. 6
HH Hour in 24 hour format from 00 to 23. 15
hh Hour in 12 hour format from 01 to 12. 03
h Hour in 12 hour format from 1 to 12. 3
mm Minute from 00 to 59. 04
m Minute from 0 to 59. 4
ss Seconds from 00 to 59. 08
s Seconds from 0 to 59. 8
FFFFFFFFF Fractional seconds with 9 digits, including zeros, on the right of the specified digits. 00.123456789
FFFFFFFF Fractional seconds with 8 digits, including zeros, on the right of the specified digits. 00.12345678
FFFFFFF Fractional seconds with 7 digits, including zeros, on the right of the specified digits. 00.1234567
FFFFFF Fractional seconds with 6 digits, including zeros, on the right of the specified digits. 00.123456
FFFFF Fractional seconds with 5 digits, including zeros, on the right of the specified digits. 00.12345
FFFF Fractional seconds with 4 digits, including zeros, on the right of the specified digits. 00.1234
FFF Fractional seconds with 3 digits, including zeros, on the right of the specified digits. 00.123
FF Fractional seconds with 2 digits, including zeros, on the right of the specified digits. 00.12
F Fractional seconds with 1 digits, including zeros, on the right of the specified digits. 00.1
fffffffff Fractional seconds with 9 digits. 987654321
ffffffff Fractional seconds with 8 digits. 98765432
fffffff Fractional seconds with 7 digits. 9876543
ffffff Fractional seconds with 6 digits. 987654
fffff Fractional seconds with 5 digits. 98765
ffff Fractional seconds with 4 digits. 9876
fff Fractional seconds with 3 digits. 987
ff Fractional seconds with 2 digits. 98
f Fractional seconds with 1 digits. 9
tt Meridian indicator (morning or evening). When formatting, this is either AM or PM. PM
t Short meridian indicator (morning or evening). Maps to the lowercase am or pm. pm
K Time zone name. PST
kk Time zone in ±xx:xx format. -8:00:00
k Timezone in ±xxxx format. -8000

Is Leap Year

Syntax
        
isLeapYear(year)
      
Description Checks if the given year is a leap year.
Input parameter year: The input year (real number).
Return type BOOLEAN
Output Returns TRUE if the year is a leap year and FALSE otherwise.

Now In Millis

Syntax
        
nowInMillis()
      
Description Returns the current Unix epoch time of an integration in milliseconds.
Input parameter N/A
Return type INT64
Output Returns the current Unix epoch time in milliseconds.

Recommendation