Skip to main content
Version: 2026.0

datetime

Datumsfunktionen für das JDito

Methods

clearTime

clearTime(pDate, pTimeZone?): number

Returns the passed date at midnight.

Parameters

pDate
number

The input date in UTC.

pTimeZone?
string | number | boolean

The time zone in which the UTC timestamp at midnight is required. If you omit this parameter, the client timezone will be used. (http:/joda-time.sourceforge.net/timezones.html)

Returns

number

The date based on the client time.


Example

let date = vars.getString("$sys.date");
let cleartime = datetime.clearTime(date, "Europe/London");



logging.log(datetime.toDate(date, "dd.MM.yyyy HH:mm:ss"));
logging.log(datetime.toDate(cleartime, "dd.MM.yyyy HH:mm:ss"));

date

date(): number

Returns the current time.

Returns

number

The current timestamp, in milliseconds, in the UTC time zone.


Example

let date = datetime.date();
logging.log("Today's date: " + datetime.toDate(date, "dd.MM.yyyy"));

getTimeZoneIDs

getTimeZoneIDs(pGeo): Map<any, any>

Returns all Timezone ID's where a geographic assignement is available as map. Example: key = "Europe/Berlin", value = "Europe/Berlin". If one of the GEO_XXX constants is applied, then all Timezones of this region are at the beginning of that map. If null or any other number is applied, then the map is in alphabetical order.

Parameters

pGeo
number

null, or one of the GEO_XXX constants.

Returns

Map<any, any>

always an ordered map where key and value are the same.


isToday

isToday(pTimestamp, pTimeZone?): boolean

Checks if the given timestamp is today in the specified timezone

Parameters

pTimestamp
number
pTimeZone?
any

Returns

boolean

true if it is today


isTomorrow

isTomorrow(pTimestamp, pTimeZone?): boolean

Checks if the given timestamp is tomorrow in the specified timezone

Parameters

pTimestamp
number
pTimeZone?
any

Returns

boolean

true if it is tomorrow


localTimestamp

localTimestamp(pDate?): string

Returns the current time in the timezone as a timestamp in ISO 8601:2000 format (2016-09-13).

Parameters

pDate?
number

The timestamp in UTC as a "long" value, e.g. as returned by $sys.date.

Returns

string

The date in the time zone of the process in the corresponding format.


Example

let time = datetime.localTimestamp(vars.getString("$sys.date"));
logging.log(time);

resolveRelativeDateExpression

resolveRelativeDateExpression(pExpression, pRelativeTo?, pTimeZone?): number[]

Will resolve the given expression into a timespan. The returned array contains the start and end time as milliseconds since epoche. The start is on index 0 and the end on index 1. This will calculate the relative timespan against the given relative date time.

If no timezone is set or this is null, "UTC" is used as default

Parameters

pExpression
string | number | boolean

The expression to resolve.

pRelativeTo?
number

The date time in milliseconds against which the relative timespan will be calculated.

pTimeZone?
string | number | boolean

the timezone of the requested date, e.g. "UTC"

Returns

number[]

Array with the start and end milliseconds.

Throws

AditoException


Example

let result = datetime.resolveRelativeDateExpression("REL=ADJUSTED;UNIT=YEAR", datetime.date(), "Europe/Berlin");

let start = result[0]; let end = result[1];

switchTimezone

switchTimezone(pTime, pFromTimeZone, pToTimeZone): number

Converts the date of any time zone to a date of another time zone.

If no timezone is set or this is null, "UTC" is used as default

Parameters

pTime
number

the date in the timezone of pFromTimeZone

pFromTimeZone
string | number | boolean

the timezone of the date, e.g. "UTC"

pToTimeZone
string | number | boolean

the timezone of the target, e.g. "UTC"

Returns

number

the converted date


Example

let result = datetime.switchTimezone(datetime.date(), vars.get("$sys.timezone"), "UTC");

timestamp

timestamp(pDate?): string

Returns the given time in UTC as a timestamp in ISO 8601:2000 format (2016-09-13).

Parameters

pDate?
number

The timestamp in UTC as a "long" value, e.g. as returned by $sys.date.

Returns

string

The date in the corresponding format, in UTC.


Example

let time = datetime.timestamp(vars.getString("$sys.date"));
logging.log(time);

toDate

toDate(pDateAsLong): string

WARNING: This function has been deprecated due to changes in the JDK that cause incorrect return values. Please use toDate instead. Converts a timestamp supplied as a "long" value, i.e. in milliseconds, to a readable string. See also "Date Formatting Patterns" in the JDito-JavaScript manual.

Parameters

pDateAsLong
string | number | boolean

The input value as an integer date value in UTC.

Returns

string

The formatted output value (client timezone).

Deprecated

Deprecated since 2025.2.0.

Throws

May throw an exception.

toDate(pDateAsLong, pPattern): string

WARNING: This function has been deprecated due to changes in the JDK that cause incorrect return values. Please use toDate instead. Converts a timestamp supplied as a "long" value, i.e. in milliseconds, to a readable string. See also "Date Formatting Patterns" in the JDito-JavaScript manual.

Example

let date = datetime.toDate(vars.getString("$sys.date"));
logging.log(date);

Example

let date = datetime.toDate(vars.getString("$sys.date"));
logging.log(date);

Parameters

pDateAsLong
string | number | boolean

The input value as an integer date value in UTC.

pPattern
undefined

The pattern to be used for forming the return value.

Returns

string

The formatted output value (client timezone).

Deprecated

Deprecated since 2025.2.0.

Throws

May throw an exception.

toDate(pDateAsLong, pPattern, pTimeZone): string

WARNING: This function has been deprecated due to changes in the JDK that cause incorrect return values. Please use toDate instead. Converts a timestamp supplied as a "long" value, i.e. in milliseconds, to a readable string. See also "Date Formatting Patterns" in the JDito-JavaScript manual.

Example

let date = datetime.toDate(vars.getString("$sys.date"));
logging.log(date);

Parameters

pDateAsLong
string | number | boolean

The input value as an integer date value in UTC.

pPattern
undefined

The pattern to be used for forming the return value.

pTimeZone
undefined

The time zone of the output value (http:/joda-time.sourceforge.net/timezones.html).

Returns

string

The formatted output value (client timezone).

Deprecated

Deprecated since 2025.2.0.

Throws

May throw an exception.

toDate(pDateAsLong, pPattern, pTimeZone, pLocale): string

WARNING: This function has been deprecated due to changes in the JDK that cause incorrect return values. Please use toDate instead. Converts a timestamp supplied as a "long" value, i.e. in milliseconds, to a readable string. See also "Date Formatting Patterns" in the JDito-JavaScript manual.

Example

let date = datetime.toDate(vars.getString("$sys.date"));
logging.log(date);

Parameters

pDateAsLong
string | number | boolean

The input value as an integer date value in UTC.

pPattern
undefined

The pattern to be used for forming the return value.

pTimeZone
undefined

The time zone of the output value (http:/joda-time.sourceforge.net/timezones.html).

pLocale
undefined

The locale of the output value

Returns

string

The formatted output value (client timezone).

Deprecated

Deprecated since 2025.2.0.

Throws

May throw an exception.

toDate(pDateAsLong, pPattern, pTimeZone?, pLocale?): string

Converts a timestamp supplied as a "long" value, i.e. in milliseconds, to a readable string using a format pattern.

See also "Date Formatting Patterns" in the JDito-JavaScript manual.

Example

let date = datetime.toDate(vars.getString("$sys.date"), "dd.MM.yyyy", "UTC", "en_US");
logging.log(date);

Parameters

pDateAsLong
string | number | boolean

The input value as an integer date value in UTC.

pPattern
string | number | boolean

The pattern to be used for forming the return value.

pTimeZone?
string | number | boolean

The time zone of the output value (http:/joda-time.sourceforge.net/timezones.html).

pLocale?
string | number | boolean

The locale of the output value

Returns

string

The formatted output value.

Throws

May throw an exception.


today

today(pTimeZone?): number

Returns the current date at midnight.

Parameters

pTimeZone?
string | number | boolean

The time zone in which the date at midnight is required.

Returns

number

The date based on the client time (not UTC) at midnight. If the timeZone parameter was specified, the system returns the date at midnight in the specified time zone.


Example

let date = datetime.today("Europe/Berlin");
logging.log("Current time: " + datetime.toDate(date, "dd.MM.yyyy HH:mm:ss"));

toLocaleDate

toLocaleDate(pDateAsLong, pPattern): string

Converts a timestamp supplied as a "long" value, i.e. in milliseconds, to a readable string using a format pattern. In this case, the client's time zone and locale are used.

See also "Date Formatting Patterns" in the JDito-JavaScript manual.

Parameters

pDateAsLong
string | number | boolean

The input value as an integer date value in UTC.

pPattern
string | number | boolean

The pattern to be used for forming the return value.

Returns

string

The formatted output value.

Throws

May throw an exception.


Example

let date = datetime.toLocaleDate(vars.getString("$sys.date"), "dd.MM.yyyy");
logging.log(date);

toLong

toLong(pDate, pPattern?, pTimeZone?): string

Converts a readable date to a "long" value.

Parameters

pDate
string | number | boolean

The input value in any date format. It must be possible to convert this date format using one of the patterns described in the "Date Formatting Patterns" section in the JDito-JavaScript manual.

pPattern?
string | number | boolean

The format of the date you passed.

pTimeZone?
string | number | boolean

The time zone of the date you passed (http:/joda-time.sourceforge.net/timezones.html).

Returns

string

The date as a "long" value in UTC.

Throws

May throw an exception.

Properties

Example

let date = datetime.toLong(datetime.toDate(vars.getString("$sys.date")), "dd.MM.yyyy", "Europe/Berlin");
logging.log("Date as Long value: " + date);

DATETIME_PATTERN_ISO_LOCAL_DATE_TIME

string

Constant: Pattern for the datetime format, defined as:

Example

yyyy-MM-dd'T'HH:mm:ss

The pattern will not be translated automatically into the current runtime locale.


DATETIME_PATTERN_ISO_OFFSET_DATE_TIME_MILLIS

string

Constant: Pattern for the datetime format including milliseconds and timezone offset, defined as:

Example

yyyy-MM-dd'T'HH:mm:ss.SSSXXX

The pattern will not be translated automatically into the current runtime locale.


GEO_AFRICA

number

Describes the geographic area of Africa.


GEO_AMERICA

number

Describes the geographic area of America.


GEO_ANTARCTICA

number

Describes the geographic area of Antarctica.


GEO_ARCTIC

number

Describes the geographic area of Arctic.


GEO_ASIA

number

Describes the geographic area of Asia.


GEO_ATLANTIC

number

Describes the geographic area of Atlantic.


GEO_AUSTRALIA

number

Describes the geographic area of Australia.


GEO_EUROPE

number

Describes the geographic area of Europe.


GEO_INDIAN

number

Describes the geographic area of Indian.


GEO_PACIFIC

number

Describes the geographic area of Pacific.


ONE_DAY

number

One day in milliseconds


ONE_HOUR

number

One hour in milliseconds


ONE_MINUTE

number

One minute in milliseconds


ONE_SECOND

number

One second in milliseconds


ONE_WEEK

number

One week in milliseconds