Format date

Value resolver – Abstract

Purpose: Converts a date value or date range in the input value to a formatted string that describes a time or interval.

In the server context (e.g. Event handling)

In the client context (e.g. Client workflow)

images/download/attachments/177910606/image2022-7-12_11-56-22-version-1-modificationdate-1726040407537-api-v2.png

images/download/attachments/177910606/image2022-7-12_11-57-23-version-1-modificationdate-1726040407534-api-v2.png


NOTE◄ The selection of a Locale is not supported on the client side. The Current locale determines the localization in the client without alternative.

The Format date value resolver converts the date value or date range present as input value into a formatted string according to the template (pattern) defined as Format.

Interpretation of date values without a declared time zone

A Long value as input value is interpreted as milliseconds since 01.01.1970 00:00:00.000 (UTC). However, as for all input value types interpreted as date without time zone (Long, Timestamp, Date), the UTC time zone is not the default. Rather, the default time zone applicable in the context is taken into account according to the following logic:

  • If a 'Default time zone' (defaultTimeZone) is defined for the User of session (in the actual logged-in session), this will be used.

  • Otherwise, the account of the Company of session (in the actual logged-in session) and the 'Default time zone' (defaultTimeZone) defined there, if applicable, are used.

  • Only if neither account defines a 'Default time zone' for the actual logged in session, the selection for the time zone in the operating system of the server or client will be the deciding factor:

For a date range, the same Format is applied for 'From' and 'To' time.

  • The return value of the value resolver shows a date range as an interval only if the formatted values (From/To) differ.

    • For example, a Relative date range with time value resolver with the 'This year' type results in the following interval when formatted with the date, time, and time zone:

      01/01/2022 12:00 AM (UTC) - 12/31/2022 11:59 PM (UTC)

  • If the formatted strings for from-time and to-time of a date range are identical, the return value does not define an interval, but only the (common) point in time.

    • For example, a Relative date range with time value resolver of the 'This day' type for a format that uses only date and time zone returns the following value:

      04/30/2022 (UTC)

Configuration

In the optional Format parameter, a so-called pattern can be specified by direct input (as static text) or via value resolvers at runtime, which defines the desired combination of date/time components in combinations with 'literals' (e.g. separators).

The optional Locale parameter is only supported for server-side use. It explicitly defines the Locale for localizations in the return value and, if applicable, the applicable default pattern.

How pattern letters in the Format parameter can be resolved at runtime depends on the context of use of the value resolver:

Operational context

Interpretation of the pattern in the 'Format' parameter

Example

Server
(e.g. in Event handling)

images/download/attachments/177910606/image2022-7-12_11-56-22-version-1-modificationdate-1726040407537-api-v2.png

Pattern syntax for the Java SimpleDateFormat with the following exceptions:

►IMPORTANT◄ Specific deviations from SimpleDateFormat

  1. The pattern letter Y ('Week year') is interpreted like y ('Year'); 'Week year' (Y) is effectively not supported by the Format date value resolver.

  2. The pattern letter D ('Day of year') is interpreted as d ('Day of month'); 'Day of year' (D) is effectively not supported by the Format date value resolver.

  • All other pattern letters for the Java SimpleDateFormat are supported.

  • Quotation marks can be used to define literals that contain pattern letters.

  • Each component may be addressed multiple times in the same pattern.

By default, date components are not localized on the server side (unlike the client, which localizes in the same way as the fd (format date) function). However, the optional Locale parameter can be used to explicitly define the Locale to be considered for localizations statically (through Static values in the configuration) or dynamically (through value resolvers of other categories).

Without assigning a Locale, the Java Locale takes effect on the server side depending on the execution context of the Lobster Data Platform / Orchestration server:

  • For quarters (QQQQ), months (MMM,MMMMM), weekdays (EEE,EEEE) and the 'AM/PM' feature (a), the texts that Java provides are output by default.

  • The Java localizations may differ from the corresponding default localizations in the lobsterui bundle. For the localization 'German' (de) Java provides the text Mär as the short form for the month 'March' (per pattern MMM). The default localization from the Localization of Lobster Data Platform / Orchestration assigns via the default localization for the Bundle/Resource combination lobsterui/monthNamesShort the text Mrz

HH:mm 'am' dd-MMMM-yyyy

returns e.g.

13:45 on 31-December-2021

... provided that the execution context of the Lobster Data Platform / Orchestration server is localized as 'English'.

Client
(e.g. in a Client workflow)

images/download/attachments/177910606/image2022-7-12_11-57-23-version-1-modificationdate-1726040407534-api-v22.png

Restricted pattern syntax as described for the fd function:

  • Only a subset of pattern letters (see Java SimpleDateFormat) is supported. Pattern letters that are not supported (e.g. W) are considered to be literal.

  • Quotation marks do not 'protect' literals that contain pattern letters. They are treated as literals.

  • Each component may be addressed max. once in the pattern, otherwise the return value is $null.

Localization of date components (via Localization or Company specific localization), as described for the fd function.

  • For quarters (QQQQ), months (MMM, MMMMM), days of the week (EEE, EEEE), and the 'AM/PM' feature (a), localization entries for the lobsterui bundle are used for the Current locale.

HH:mm 'am' dd-MMMM-yyyy

always returns $null , because...

  • the quotation marks do not protect the literal 'am',

  • whose characters are then interpreted as pattern letters and

  • the component 'minutes' (m) is therefore incorrectly addressed twice.


HH:mm ~ dd-MMMM-yyyy

returns e.g.:

13:45 ~ 31-December-2021

Without specifying a pattern for the Format string, localization entries from the Localization or Company specific localization are assigned as default patterns according to the following scheme:

Scheme for the default pattern
[lobsterui,dateFormat] [lobsterui,timeFormat]

Localization provides the following localizations for the default pattern by default:

Component

Bundle

Resource

Locale

Default pattern

Example

Date

lobsterui

dateFormat

German (de)

DD.MM.YYYY

31.12.2021

English (en)

MM/DD/YYYY

12/31/2021

Time

timeFormat

German (de)

HH:mm

13:45

English (en)

hh:mm a

01:45 PM

The two components (Date and Time) are output together (separated by a space) by default.

NOTE◄ The patterns stored as localization texts should be defined to match the more restrictive syntax for the client context (see table above). Otherwise, the Format date value resolver in client-side use will always return $null if no Format is specified.

Other default localizations in the Localization that may be relevant for the output:

Component

Pattern

Bundle

Resource

Locale

Default

Date

MonthMMMM

lobsterui

monthNames

German (de)

Januar,Februar,März,April,Mai,Juni,Juli,August,September,Oktober,November,Dezember

English (en)

January,February,March,April,May,June,July,August,September,October,November,December

Month (short)
MMM

monthNamesShort

German (de)

Jan,Feb,Mrz,Apr,Mai,Jun,Jul,Aug,Sep,Okt,Nov,Dez

English (en)

Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec

Weekday
dddd

dayNames

German (de)

Sonntag,Montag,Dienstag,Mittwoch,Donnerstag,Freitag,Samstag

English (en)

Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday

Weekday (short)
ddd

dayNamesShort

German (de)

So,Mo,Di,Mi,Do,Fr,Sa

English (en)

Sun,Mon,Tue,Wed,Thu,Fri,Sat

Quarter
QQQQ

quarterNames

German (de)

erstes Quartal,zweites Quartal,drittes Quartal,viertes Quartal

English (en)

first quarter,second quarter,third quarter,fourth quarter

Time



AM/PM
a

am

German (de)

vorm.

English (en)

AM

pm

German (de)

nachm.

English (en)

PM

Examples

Formatting a date value

Configuration

Result (in the server context)

Result (in the client context) with the locale 'German' (de)

images/download/attachments/177910606/image2019-3-15_14-29-39-version-1-modificationdate-1726040407619-api-v2.png

images/download/attachments/177910606/image2022-7-7_9-37-58-version-1-modificationdate-1726040407657-api-v2.png

Due to the settings for the Lobster Data Platform / Orchestration server execution context, the date format (here) always appears in Java 'English'

images/download/attachments/62856297/image2022-7-5_16-41-52-version-1-modificationdate-1657032112702-api-v2.png

In the client, the localizations for the locale 'German' (de) are taken into account.

In this example, the current time is determined by a Relative date with time resolver to display it in a special format in a message.

The Format date value resolver is used by concatenation to format the output of date and time (here incl. time zone).

Formatting by default date and time settings from localization

Configuration

Result (EN)

Result (DE)

images/download/attachments/177910606/image2019-3-15_14-36-22-version-1-modificationdate-1726040407624-api-v2.png

Without parameters the default formats for date and time from the localization (see above) are applied.

If, on the other hand, the Format date value resolver were completely omitted in the context of the message, then the message would display the string image for the 'Relative date range with time' in the following format:

2019-03-10 23:00:00.000 UTC- 2019-03-16 23:00:00.000 UTC

images/download/attachments/177910606/image2019-3-15_14-36-57-version-1-modificationdate-1726040407627-api-v2.png

Based on the following localization entries:

images/download/attachments/177910606/image2019-3-15_14-39-31-version-1-modificationdate-1726040407632-api-v2.png

images/download/attachments/177910606/image2019-3-15_14-38-7-version-1-modificationdate-1726040407629-api-v2.png

Based on the following localization entries:

images/download/attachments/177910606/image2019-3-15_14-41-32-version-1-modificationdate-1726040407634-api-v2.png

IMPORTANT◄ If the default pattern defined via the localization entry contains localizable components (e.g. the EEEE pattern for the day of the week), the result will differ depending on the deployment context (server: depends on Java Locale, client: Current locale) as shown above.

The server-side execution context also governs other aspects of date handling in Lobster Data Platform / Orchestration. This includes, among other things, the setting for the first day of the week. Whether the 'Current week' – as above left – is delimited from Monday (03/10/2019) to Sunday or – as above right – from Sunday (11/03/2019) to Monday, depends solely on the server-side setting for the first day of the week. The two screenshots were therefore generated on two different systems.

NOTE◄ The Localization contains an entry lobsterui/firstDayOfWeek, which is only relevant for the display of DatePicker elements (e.g. Date/Time and Date range) in the interactive interface. .

Formatting date and time for a specific locale

In the context of event handling, the 'Subject' of a booking confirmation e-mail explicitly reflects the booking date using the localization specified in Lobster Data Platform / Orchestration for the en_US language.

The output should look like this without regard to the Current locale for a posting for 07/04/2022: 'CONFIRMED: MON04JUL22'.

Configuration:

In the Subject of the E-Mail event action, the text output is generated by the concatenation of value resolvers shown on the right:

  • The Variable value resolver reads the booking date (type 'Date with time') from the confirmedSlot variable.

  • In the Format date value resolver, the Format associated with the literal characters for the labeling plain text 'CONFIRMED:' is set as:
    'CONFIRMED: 'EEEddMMMyy

  • For the Locale, the Locale 'English (US)' (en_US) is defined here for the localization by a static selection in the configuration.

  • Finally, the Upper case value resolver ensures that the abbreviations for day of week (EEE) and month (MMM) appear in upper case.

images/download/attachments/177910606/image2022-7-12_12-3-9-version-1-modificationdate-1726040407516-api-v2.png

NOTE◄ The single quotation marks ('...') are absolutely necessary here so that the text 'CONFIRMED: ' is processed as a literal. Otherwise already the first letter ('C') causes an error message (IllegalArgumentException: Illegal pattern character).