Syntax for time periods
Time can be specified in XDM as a duration or as a period. A duration is used when the user has to specify a shorter time range in the size of minutes, hours or days. Periods define longer time ranges in days, months or years. Both are based on the ISO 8601 format.
Syntax for time duration
The duration has the following syntax:
P<n>DT<n>H<n>M<n>S
The 'P' designator is required at the beginning of the expression. After it the expression <n>'D' can be placed but this is optional. The following section has to begin with a 'T' and starts the definition of a time. If there is no time section, the 'D' section must be provided. A time has to be specified by hours, minutes and seconds and at least one of them must be given if the 'T' is present. The order of the sections is important and must not be interchanged. Skipping sections is allowed.
<n> must be replaced by the value for each of the date and time elements that follow the <n>. Leading zeros are not required.
-
P is the duration designator (for period) placed at the start of the duration representation.
-
D is the day designator that follows the value for the number of days.
-
-
T is the time designator that precedes the time components of the representation.
-
H is the hour designator that follows the value for the number of hours.
-
M is the minute designator that follows the value for the number of minutes.
-
S is the second designator that follows the value for the number of seconds.
-
| Value | Result |
|---|---|
P5D |
5 days |
PT3H |
3 hours |
PT4M |
4 minutes |
P2DT3H4M |
2 days, 3 hours, and 4 minutes |
More details can be found at the Java API documentation of the Duration.parse() method.
Syntax for time period
The period has the following syntax:
P<n>Y<n>M<n>W<n>D
The 'P' designator is required at the beginning of the expression. After it there are 4 sections, each consisting of a number and a suffix. At least one of these sections must be specified. The order of the sections is important and must not be interchanged. Skipping sections is allowed.
In the expression above, <n> must be replaced by the value for each of the date and time elements that follow the <n>. Leading zeros are not required.
-
P is the duration designator (for period) placed at the start of the duration representation.
-
Y is the year designator that follows the value for the number of years.
-
M is the month designator that follows the value for the number of months.
-
W is the week designator that follows the value for the number of weeks.
-
D is the day designator that follows the value for the number of days.
-
| Value | Result |
|---|---|
P2Y |
2 years |
P3M |
3 months |
P4W |
4 weeks |
P5D |
5 days |
P1Y2M3W4D |
1 year, 2 months, 3 weeks and 4 days |
More details can be found at the Java API documentation of the Period.parse() method.