Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Info
titleAvailability

This routine is available since starting with katl-commons 1.0.

Syntax

...

formatDate(date, format)

Description

...

Excerpt

Formats the given date into a date/time string accordingly to the given format expression.

Parameters

...

Parameter name

Type

Required

Description

date

date

Yes

Specifies a Date or DateTime expression

formatstringYesSpecifies a pattern expression representing the desired date format

Return type

...

string

The return value represents the formatted string representation for the given date.

Example

...

Example 1

...

Code Block
string format = "yyyy.MM.dd G 'at' HH:mm:ss z";
print("Current time is " + formatDate(currentDate(), format));

Assuming that current date is 30.10.2011 and time 12:08, prints Today is 2011.10.30 AD at 12:08:00 PDT

Example 2

...

Code Block
date varDateTime = "2011-08-17T18:30:55";
string format = "EEE, d MMM yyyy HH:mm:ss Z";
print("Formatted date is " + formatDate(varDateTime, format));

...

Info

For a full set of date formats that can be used, check out the SimpleDateFormat documentation from Oracle.

See

...

also

Filter by label (Content by label)
showLabelsfalse
max100
showSpacefalse
cqllabel = "date_routines"
labelsdate_routines