DateTime.translateTime()

Signature

DateTime translateTime(DateTime date, String tz)

Domain

action, condition

Description

Translate a time to a new timezone and return the new translated DateTime object

Parameters

NameTypeDescription
dateDateTimeThe DateTime to be translated.
tzStringThe Time Zone ID. If null, use the default TimeZone.

Returns

TypeDescription
DateTimeThe new translated DateTime of timezone tz.

Cautions

none

Example


DateTime dateNow = DateTime.now ();
DateTime newDate = DateTime.translateTime(dateNow, "GMT");
String result = DateTime.format(newDate, "yyyy-MM-dd HH:mm:ss z")

Result is: "2005-08-19 12:39:37 GMT"