dateTimeBuild


Builds a date/time String based on the specified pattern and date/time units.

Parameters


Combine the parameters as a JSON structure as input.

Parameter Mandatory/Optional Data Type Description
pattern Mandatory String The format of the returned date.
year Optional String The year in yyyy format (for example: 2021). If none or an invalid value is specified, dateTimeBuild will use the current year.
month Optional String The month in number format (for example: 1 for January, 2 for February, etc.). If none or an invalid value is specified, dateTimeBuild will use the current month.
dayofmonth Optional String The day of the month in number format (for example: 1 for the first day of the month, 2 for the second day of the month, etc.). If none or an invalid value is specified, dateTimeBuild will use the current day.
hour Optional String The hour in number format based on 24-hour clock (for example: 0 for midnight, 2 for 2 AM, 14 for 2 PM). If none or an invalid value is specified, dateTimeBuild will use the 0 as the value.
minute Optional String The minutes in number format. If none or an invalid value is specified, dateTimeBuild will use the 0 as the value.
second Optional String The seconds in number format. If none or an invalid value is specified, dateTimeBuild will use the 0 as the value.
millis Optional String The milliseconds in number format. If none or an invalid value is specified, dateTimeBuild will use the 0 as the value.
timezone Optional String The timezone for the returned date/time, such as GMT for Greenwich Mean Time. If not specified, GMT is used by default.
locale Optional String
Locale for the returned date/time. For example, if locale is EN (English), and pattern is EEE d MMM yyyy, the returned result will be Thu 2000-04-13 01:45:33. If not specified, EN is used by default. The locales currently supported are:
  • EN: English
  • CH: Chinese

Return Values

Value Data Type Description
value String The date/time built according to year, month, dayofmonth, hour, minute, second and millis, in the format as per specified in pattern.

Samples

var format=tools.DateUtil.dateTimeBuild({"month":"7","year":"2000","timezone":"GMT","pattern":"EEE yyyy-MM-dd hh:mm:ss","dayofmonth":"18","hour":"19","minute":"22","second":"10","millis":"3","locale":"CH"});
return tools.resultBuilder.build(true, JSON.stringify(format));


Output

"Tue 2000-07-18 07:22:10"