%dw 2.0
import * from dw::core::Periods
output application/json
---
{
nextSecond: |2020-10-05T20:22:34.385Z| + seconds(1),
previousSecond: |2020-10-05T20:22:34.385Z| - seconds(1),
decimalInputPeriod: seconds(4.555),
wholeNumberInputPeriod: seconds(4),
addNegativeValue: seconds(-1) + seconds(2)
}
DataWeave
seconds
seconds(nSecs: Number): Period
Creates a Period value from the provided number of seconds.
Introduced in DataWeave version 2.4.0.
Parameters
Name | Description |
---|---|
|
The number of seconds as a whole or decimal number. A positive or negative number is valid. |
Example
This example shows how seconds
behaves with different inputs.
It adds and subtracts seconds from DateTime values. It also converts
the decimal value 4.555
into the Period format (PT4.555S
) and
and the whole number 4
into the Period format (PT4S
)
Source
Output
{
"nextSecond": "2020-10-05T20:22:35.385Z",
"previousSecond": "2020-10-05T20:22:33.385Z",
"decimalInputPeriod": "PT4.555S",
"wholeNumberInputPeriod": "PT4S",
"addNegativeValue": 1
}
Json