toPeriod

toPeriod(str: String): Period

Transform a String value into a Period value.

Introduced in DataWeave version 2.4.0.

Parameters

Name Description

str

The String value to transform into a Period value.

Example

This example shows how toPeriod behaves with different inputs. It produces output in the application/dw format.

Source

%dw 2.0
import * from dw::util::Coercions
output application/dw
---
{
  toPeriodEx1: toPeriod("P1D"),
  toPeriodEx2: toPeriod("PT1H1M")
}

Output

{
  toPeriodEx1: |P1D|,
  toPeriodEx2: |PT1H1M|
}

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub