DateTime.createTime()
Signature
createTime(int year, int month, int date, int hrs, int min, int sec, String tz)
Description
Create a DateTime object of a particular timezone. Month value is 0-based. 0 for January, 11 for December.
Parameters
Name | Type | Description |
year | int | The value of the YEAR time field. |
month | int | The value of the MONTH time field. Month value is 0-based. e.g., 0 for January. |
date | int | The value of the DATE time field. The day of month value between 1-31. |
hour | int | The value of the HOUR time field. Hour value between 0-23. |
min | int | The value of the MINUTE time field. Minute value between 0-59. |
sec | int | The value of the SECOND time field. Second value between 0-59. |
tz | String | The Time Zone ID. If null, the default TimeZone will be used. |
Returns
Type | Description |
DateTime | The created DateTime with timezone set to tz. |
Example
DateTime date = DateTime.createTime(2005, 7, 19, 12, 39, 37, "GMT");
String result = DateTime.format(date, "yyyy-MM-dd HH:mm:ss z")
Result is: "2005-08-19 12:39:37 GMT"