ng:dateTimeFormat

ng:dateTimeFormat

This section desribes the built-in function, ng:dateTimeFormat(xmlDateTime, dateFormat, part, locale, customErrorMessage)

The function converts an XML date and time (timestamp) into the format of your choice.

 

An alternative to this function is ng:dateFormat

 

This function returns a formatted date-time string and has these input parameters:

 

xmlDateTime

The date and time in the XML date-time format or just the date (format YYYY-MM-DD). If this parameter is empty (null) then the output is empty (null).

 

dateFormat

Optional input string with valid values: SHORT, MEDIUM, LONG, FULL, MASK.

SHORT will result in the most compact output, while FULL give the most verbose output. MASK is for custom output. If not specified, then the default is SHORT.

 

part

Optional input string. When MASK is used above as dateFormat, the part must specify the mask in Java SimpleDateFormat format. For other dateFormat values, this can be DATE if you only want the date part in the output, TIME if you only want the time part in the output or AUTO for both. If not specified, then the default is AUTO.

Possible output formats for MASK are listed here: https://docs.oracle.com/javase/10/docs/api/java/text/SimpleDateFormat.html

 

locale

An optional input specifying the locale to use when creating the string. If this parameter is not specified, then the locale setup on the template settings is used if used in a template (en-GB is used by default in the workflow).

Note that the designer result view can only display an approximation of the actual rendered result.

Possible values for the locale can be found on the drop down list on e.g. the Translation element.

You can also find a list of locales here: https://www.oracle.com/java/technologies/javase/jdk8-jre8-suported-locales.html

 

customErrorMessage

Optional input which specifies the value to return, if the function cannot successfully convert the input date to the requested format (e.g. if the first parameter is not a valid date). If not specified InterFormNG2 will return the Xpath specifications.

 

 

Please notice, that ng:dateTimeFormat follows the rules of the link to the date formats above for the part paramter, so you should look out for these details:

 

In the format you need to specify a capital ‘M’ for the month. (A small, ‘m’ is the minute of the hour, so you probably do NOT want that..).

‘E’ selects the day of the week.

The length of identical characters sets the ‘length type’ e.g.:

‘E’, ‘EE’ or ‘EEE’ means ‘Fri’,

‘EEEE’ means ‘Friday’.

‘M’ means the month without preceding ‘0'.

‘MM’ means the month with preceding ‘0' for months 1-9.

‘MMM’ means the short name of the month e.g. ‘Jan’

‘MMMM’ means the long name of the month e.g. ‘January’.  

 

 

Examples:

 

Xpath

Output

ng:dateTimeFormat('2002-05-30T09:30:10Z')

30/05/02 11:30

ng:dateTimeFormat('2002-05-30T09:30:10Z', 'LONG', 'DATE', 'de-DE')

30. Mai 2002

ng:dateTimeFormat('2002-05-30T09:30:10', 'LONG', 'AUTO', 'de-DE')

30. Mai 2002 11:30:10 MESZ

ng:dateTimeFormat('2002-05-30T09:30:10Z', 'MASK', 'EEEE, d MMM yyyy HH:mm:ss', 'de-DE')

Donnerstag, 30 Mai 2002 11:30:10

ng:dateTimeFormat('2022-12-24', 'LONG', 'DATE', 'de-DE')

24. Dezember 2022

ng:dateTimeFormat('2022-12-24', 'LONG', 'DATE', 'en-US')

December 24, 2021

ng:dateTimeFormat('2022-12-24', 'SHORT', 'DATE', 'de-DE')

24.12.22

ng:dateTimeFormat('2022-12-24', 'SHORT', 'DATE', 'en-US')

12/24/22

    • Related Articles

    • ng:dateFormat

      This section explains the built-in XPath function: ng:dateFormat(dateString, inputPattern, outputPattern, locale, customErrorMessage) This function returns a formatted date string, formatted using the Java SimpleDateFormat function (like InterFormNG ...
    • ng:resourceExist

      ng:resourceExist(resource,path) This function checks, if a resource in InterFormNG2 exists or not. The function returns a boolean: true or false. The ng:resourceExist Xpath function has this format: ng:resourceExist(resource,path), where: resource ...
    • ng:decrypt

      The built-in function, ng:decrypt is linked with the encryption functions: ng:encrypt and the workflow component, Set secure workflow variable. The function, ng:decrypt can decrypt contents, that was previously encrypted with these functions. The ...
    • ng:minimum

      InterFormNG2 includes the special built-in XPath function, ng:minimum. This function returns the smallest value of two numeric arguments. The function only accepts two numeric arguments - no more and no less. Examples: ng:minimum(-14,2) returns 2 ...
    • ng:base64

      The built-in function, ng:base64 converts a string (text) into a base64 based string. This can e.g. be used, if you want to insert any kind of data into an XML node, without substituting any characters, that are not allowed. This function is related ...