What does ‘PT’ prefix stand for in Duration?

As can be found on the page Jesper linked to (ISO-8601 – Data elements and interchange formats – Information interchange – Representation of dates and times)

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.
T is the time designator that precedes the time components of the representation.

So P means ‘Period’ and because there are no date-components it only has a ‘Time’.

You could interpret this as ‘Period of Time’

The ‘why’ this was chosen, you have to ask the ISO members that wrote the standard, but my guess is that it is easier to parse. (short and unambigious)

The details for the time component are:

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. 

The value of PT20S then parses to:

  • Period
  • Time
  • 20
  • Seconds

So, a duration of 20 seconds.

More examples can be found in the javadoc: https://docs.oracle.com/javase/8/docs/api/java/time/Duration.html#parse-java.lang.CharSequence-

Leave a Comment