Contact Us 1-800-596-4880

dateTime

dateTime(parts: DateTimeFactory): DateTime

Creates a DateTime value from values specified for year, month, day, hour, minutes, seconds, and timezone fields.

Introduced in DataWeave version 2.4.0.

Parameters

Name Description

parts

Number values for year, month, day, hour, minutes, and seconds fields followed by a TimeZone value for the timezone field. Valid values are numbers between 1 and 12 for the month, 1 through 31 for the day, 0 through 23 for the hour, 0 through 59 for minutes, and 0 through 59 (including decimals, such as 59.99) for seconds. You can specify the name-value pairs in any order, but the output is ordered by default as a DateTime value, such as 2012-10-11T10:10:10-03:00. The input fields are parts of a DateTimeFactory type.

Example

This example shows how to create a value of type DateTime.

Source

%dw 2.0
import * from dw::core::Dates
output application/json
---
{
    newDateTime: dateTime({year: 2012, month: 10, day: 11, hour: 12, minutes: 30, seconds: 40 , timeZone: |-03:00|})
}

Output

{
   "newDateTime": "2012-10-11T12:30:40-03:00"
}