This module contains functions to create and manipulate Date types.
Introduced in DataWeave 2.4.0. Supported by Mule 4.4.0 and later.
Functions
atBeginningOfDay
atBeginningOfDay(DateTime): DateTime
Returns a new DateTime but at the beginning of the day of the given DateTime
Introduced in DataWeave 2.4.0. Supported by Mule 4.4.0 and later.
Parameters
Name | Description |
---|---|
dateTime |
The dateTime to be used as reference |
Example
This example shows how it transforms the DateTime 2020-10-06T18:23:20.351-03:00
to the same date but at the start of the given day.
Source
1
2
3
4
5
6
%dw 2.0
output application/json
---
{
"atBeginningOfDayDateTime": atBeginningOfDay(|2020-10-06T18:23:20.351-03:00|)
}
Output
1
2
3
{
"atBeginningOfDayDateTime": "2020-10-06T00:00:00-03:00"
}
atBeginningOfDay(LocalDateTime): LocalDateTime
Returns a new LocalDateTime but at the beginning of the day of the given LocalDateTime
Introduced in DataWeave 2.4.0. Supported by Mule 4.4.0 and later.
Parameters
Name | Description |
---|---|
dateTime |
The dateTime to be used as reference |
Example
This example shows how it transforms the LocalDateTime 2020-10-06T18:23:20.351-03:00
to the same date but at the start of the given day.
Source
1
2
3
4
5
6
%dw 2.0
output application/json
---
{
"atBeginningOfDayLocalDateTime": atBeginningOfDay(|2020-10-06T18:23:20.351|)
}
Output
1
2
3
{
"atBeginningOfDayLocalDateTime": "2020-10-06T00:00:00"
}
atBeginningOfHour
atBeginningOfHour(DateTime): DateTime
Returns a new DateTime with the Time changed to the start of the current hour
Introduced in DataWeave 2.4.0. Supported by Mule 4.4.0 and later.
Parameters
Name | Description |
---|---|
dateTime |
The DateTime used as reference |
Example
This shows how it changes the specified Time to the the start of the given hour.
Source
1
2
3
4
5
6
%dw 2.0
output application/json
---
{
"atBeginningOfHour": atBeginningOfHour(|2020-10-06T18:23:20.351-03:00|)
}
Output
1
2
3
{
"atBeginningOfHour": "2020-10-06T18:00:00-03:00"
}
atBeginningOfHour(LocalDateTime): LocalDateTime
Returns a new LocalDateTime changed to the beginning of the given hour
Introduced in DataWeave 2.4.0. Supported by Mule 4.4.0 and later.
Parameters
Name | Description |
---|---|
localDateTime |
The LocalDateTime used as reference |
Example
This shows how it changes the specified Time to the the start of the given hour.
Source
1
2
3
4
5
6
%dw 2.0
output application/json
---
{
"atBeginningOfHour": atBeginningOfHour(|2020-10-06T18:23:20.351|)
}
Output
1
2
3
{
"atBeginningOfHour": "2020-10-06T18:00:00"
}
atBeginningOfHour(LocalTime): LocalTime
Returns a new LocalTime changed to the start of the current hour
Introduced in DataWeave 2.4.0. Supported by Mule 4.4.0 and later.
Parameters
Name | Description |
---|---|
dateTime |
Example
This shows how it changes the specified LocalTime to the the start of the given hour.
Source
1
2
3
4
5
6
%dw 2.0
output application/json
---
{
"atBeginningOfHour": atBeginningOfHour(|18:23:20.351|)
}
Output
1
2
3
{
"atBeginningOfHour": "18:00:00"
}
atBeginningOfHour(Time): Time
Returns a new Time changed to the beginning of the given hour.
Introduced in DataWeave 2.4.0. Supported by Mule 4.4.0 and later.
Parameters
Name | Description |
---|---|
time |
The time to be used as reference |
Example
This shows how it changes the specified Time to the the start of the given hour.
Source
1
2
3
4
5
6
%dw 2.0
output application/json
---
{
"atBeginningOfHour": atBeginningOfHour(|18:23:20.351-03:00|)
}
Output
1
2
3
{
"atBeginningOfHour": "18:00:00-03:00"
}
atBeginningOfMonth
atBeginningOfMonth(DateTime): DateTime
Returns a new DateTime but at the beginning of the Month of the given DateTime
Introduced in DataWeave 2.4.0. Supported by Mule 4.4.0 and later.
Parameters
Name | Description |
---|---|
dateTime |
The dateTime to be used as reference |
Example
This example shows how it transforms the DateTime 2020-10-06T18:23:20.351-03:00
to the same date but at the start of the given Month.
Source
1
2
3
4
5
6
%dw 2.0
output application/json
---
{
atBeginningOfMonth(|2020-10-06T18:23:20.351-03:00|)
}
Output
1
2
3
{
"atBeginningOfMonth": "2020-10-01T00:00:00-03:00"
}
atBeginningOfMonth(LocalDateTime): LocalDateTime
Returns a new LocalDateTime but at the beginning of the Month of the given LocalDateTime
Introduced in DataWeave 2.4.0. Supported by Mule 4.4.0 and later.
Parameters
Name | Description |
---|---|
dateTime |
The localDateTime to be used as reference |
Example
This example shows how it transforms the LocalDateTime 2020-10-06T18:23:20.351
to the same date but at the start of the given Month.
Source
1
2
3
4
5
6
%dw 2.0
output application/json
---
{
"atBeginningOfMonth": atBeginningOfMonth(|2020-10-06T18:23:20.351|)
}
Output
1
2
3
{
"atBeginningOfMonth": "2020-10-01T00:00:00"
}
atBeginningOfMonth(Date): Date
Returns a new Date but at the beginning of the Month of the given Date
Introduced in DataWeave 2.4.0. Supported by Mule 4.4.0 and later.
Parameters
Name | Description |
---|---|
dateTime |
The date to be used as reference |
Example
This example shows how it transforms the Date |2020-10-06| to the same date but at the start of the given Month.
Source
1
2
3
4
5
6
%dw 2.0
output application/json
---
{
atBeginningOfMonthDate: atBeginningOfMonth(|2020-10-06|)
}
Output
1
2
3
{
"atBeginningOfMonth": "2020-10-01"
}
atBeginningOfWeek
atBeginningOfWeek(DateTime): DateTime
Returns a new DateTime but at the beginning of the Week of the given DateTime
Introduced in DataWeave 2.4.0. Supported by Mule 4.4.0 and later.
Parameters
Name | Description |
---|---|
dateTime |
The dateTime to be used as reference |
Example
This example shows how it transforms the DateTime |2020-10-06T18:23:20.351-03:00| to the same date but at the start of the given Week.
Source
1
2
3
4
5
6
%dw 2.0
output application/json
---
{
atBeginningOfWeekDateTime: atBeginningOfWeek(|2020-10-06T18:23:20.351-03:00|)
}
Output
1
2
3
{
"atBeginningOfMonth": "2020-10-04T00:00:00-03:00"
}
atBeginningOfWeek(LocalDateTime): LocalDateTime
Returns a new LocalDateTime but at the beginning of the Week of the given LocalDateTime
Introduced in DataWeave 2.4.0. Supported by Mule 4.4.0 and later.
Parameters
Name | Description |
---|---|
localDateTime |
The localDateTime to be used as reference |
Example
This example shows how it transforms the LocalDateTime |2020-10-06T18:23:20.351| to the same date but at the start of the given Week.
Source
1
2
3
4
5
6
%dw 2.0
output application/json
---
{
atBeginningOfMonth: atBeginningOfWeek(|2020-10-06T18:23:20.351|)
}
Output
1
2
3
{
"atBeginningOfMonth": "2020-10-04T00:00:00"
}
atBeginningOfWeek(Date): Date
Returns a new Date but at the beginning of the Week of the given Date
Introduced in DataWeave 2.4.0. Supported by Mule 4.4.0 and later.
Parameters
Name | Description |
---|---|
date |
The date to be used as reference |
Example
This example shows how it transforms the Date |2020-10-06| to the same date but at the start of the given Week.
Source
1
2
3
4
5
6
%dw 2.0
output application/json
---
{
atBeginningOfMonth: atBeginningOfWeek(|2020-10-06|)
}
Output
1
2
3
{
"atBeginningOfMonth": "2020-10-04"
}
atBeginningOfYear
atBeginningOfYear(DateTime): DateTime
Returns a new DateTime but at the beginning of the Year of the given DateTime
Introduced in DataWeave 2.4.0. Supported by Mule 4.4.0 and later.
Parameters
Name | Description |
---|---|
dateTime |
The dateTime to be used as reference |
Example
This example shows how it transforms the DateTime |2020-10-06T18:23:20.351-03:00| to the same date but at the start of the given Year.
Source
1
2
3
4
5
6
%dw 2.0
output application/json
---
{
atBeginningOfYear: atBeginningOfYear(|2020-10-06T18:23:20.351-03:00|)
}
Output
1
2
3
{
"atBeginningOfYear": "2020-01-01T00:00:00.000-03:00"
}
atBeginningOfYear(LocalDateTime): LocalDateTime
Returns a new LocalDateTime but at the beginning of the Year of the given LocalDateTime
Introduced in DataWeave 2.4.0. Supported by Mule 4.4.0 and later.
Parameters
Name | Description |
---|---|
localDateTime |
The localDateTime to be used as reference |
Example
This example shows how it transforms the LocalDateTime |2020-10-06T18:23:20.351| to the same date but at the start of the given Year.
Source
1
2
3
4
5
6
%dw 2.0
output application/json
---
{
atBeginningOfYear: atBeginningOfYear(|2020-10-06T18:23:20.351|)
}
Output
1
2
3
{
"atBeginningOfYear": "2020-01-01T00:00:00.000"
}
atBeginningOfYear(Date): Date
Returns a new Date but at the beginning of the Year of the given Date
Introduced in DataWeave 2.4.0. Supported by Mule 4.4.0 and later.
Parameters
Name | Description |
---|---|
date |
The date to be used as reference |
Example
This example shows how it transforms the Date |2020-10-06| to the same date but at the start of the given Year.
Source
1
2
3
4
5
6
%dw 2.0
output application/json
---
{
atBeginningOfYear: atBeginningOfYear(|2020-10-06|)
}
Output
1
2
3
{
"atBeginningOfYear": "2020-01-01"
}
date
date(DateFactory): Date
Creates a Date value with the given date properties (year, month, day).
Introduced in DataWeave 2.4.0. Supported by Mule 4.4.0 and later.
Parameters
Name | Description |
---|---|
parts |
The date fields |
Example
This example shows how to create a value of type Date
Source
1
2
3
4
5
6
7
8
9
10
%dw 2.0
output application/json
---
%dw 2.0
output application/json
import * from dw::core::Dates
---
{
newDate: date({year: 2012, month: 10, day: 11})
}
Output
1
2
3
{
"newDate": "2012-10-11"
}
dateTime
dateTime(DateTimeFactory): DateTime
Creates a DateTime value with the given datetime properties (year, month, day, hour, minutes, seconds and timeZone).
Introduced in DataWeave 2.4.0. Supported by Mule 4.4.0 and later.
Parameters
Name | Description |
---|---|
parts |
The date fields |
Example
This example shows how to create a value of type DateTime
Source
1
2
3
4
5
6
7
8
9
10
%dw 2.0
output application/json
---
%dw 2.0
output application/json
import * from dw::core::Dates
---
{
newDateTime: dateTime({year: 2012, month: 10, day: 11, hour: 10, minutes: 10, seconds: 10 , timeZone: |-03:00|})
}
Output
1
2
3
{
"newDateTime": "2012-10-11T10:10:10-03:00",
}
localDateTime
localDateTime(LocalDateTimeFactory): LocalDateTime
Creates a LocalDateTime value with the given localDatetime properties (year, month, day, hour, minutes, seconds).
Introduced in DataWeave 2.4.0. Supported by Mule 4.4.0 and later.
Parameters
Name | Description |
---|---|
parts |
The localDateTime fields |
Example
This example shows how to create a value of type DateTime
Source
1
2
3
4
5
6
7
8
9
10
%dw 2.0
output application/json
---
%dw 2.0
output application/json
import * from dw::core::Dates
---
{
newLocalDateTime: localDateTime({year: 2012, month: 10, day: 11, hour: 10, minutes: 10, seconds: 10})
}
Output
1
2
3
{
"newLocalDateTime": "2012-10-11T10:10:10",
}
localTime
localTime(LocalTimeFactory): LocalTime
Creates a LocalTime value with the given localtime properties (hour, minutes, seconds).
Introduced in DataWeave 2.4.0. Supported by Mule 4.4.0 and later.
Parameters
Name | Description |
---|---|
parts |
The localTime fields |
Example
This example shows how to create a value of type LocalTime
Source
1
2
3
4
5
6
7
8
9
10
%dw 2.0
output application/json
---
%dw 2.0
output application/json
import * from dw::core::Dates
---
{
newLocalTime: localTime({ hour: 10, minutes: 10, seconds: 10}),
}
Output
1
2
3
{
"newLocalTime": "10:10:10"
}
time
time(TimeFactory): Time
Creates a Time value with the given time properties (hour, minutes, seconds and timeZone).
Introduced in DataWeave 2.4.0. Supported by Mule 4.4.0 and later.
Parameters
Name | Description |
---|---|
parts |
The time fields |
Example
This example shows how to create a value of type Time
Source
1
2
3
4
5
6
7
8
9
10
%dw 2.0
output application/json
---
%dw 2.0
output application/json
import * from dw::core::Dates
---
{
newTime: time({ hour: 10, minutes: 10, seconds: 10 , timeZone: |-03:00|}),
}
Output
1
2
3
{
"newTime": "10:10:10-03:00"
}
today
today(): Date
Returns the Date for today.
_Introduced in DataWeave 2.4.0. Supported by Mule 4.4.0 and later._
Example
This example shows the output of today
function.
Source
1
2
3
4
%dw 2.0
output application/json
---
today()
Output
1
"2020-10-06"
tomorrow
tomorrow(): Date
Returns the Date for tomorrow.
_Introduced in DataWeave 2.4.0. Supported by Mule 4.4.0 and later._
Example
This example shows the output of tomorrow
function.
Source
1
2
3
4
%dw 2.0
output application/json
---
tomorrow()
Output
1
"2020-10-07"
yesterday
yesterday(): Date
Returns the Date for yesterday.
_Introduced in DataWeave 2.4.0. Supported by Mule 4.4.0 and later._
Example
This example shows the output of today
function.
Source
1
2
3
4
%dw 2.0
output application/json
---
yesterday()
Output
1
"2020-10-05"
Types
DateFactory
1
{ day: Number, month: Number, year: Number }
DateTimeFactory
1
DateFactory & LocalTimeFactory & Zoned
LocalDateTimeFactory
1
DateFactory & LocalTimeFactory
LocalTimeFactory
1
{ hour: Number, minutes: Number, seconds: Number }
TimeFactory
1
LocalTimeFactory & Zoned
Zoned
1
{ timeZone: TimeZone }