BackendBench
Coffee
Free tool

ISO-8601 duration converter

Decode PT15M, P1DT2H and friends into seconds, or turn seconds into an ISO-8601 string. Tells you if Java's Duration or Period can parse it.

From seconds to ISO-8601

Durations in code and config

ISO-8601 durations are the standard text format for lengths of time. Spring Boot reads them in configuration, Java parses them with Duration.parse("PT15M"), and many APIs return them. They are compact but easy to misread: the M means months before the T and minutes after it, so P1M and PT1M are very different.

Frequently asked questions

What does PT15M mean?

ISO-8601 durations start with P (period). Date parts follow (years Y, months M, weeks W, days D). A T introduces the time parts: hours H, minutes M and seconds S. So PT15M is 15 minutes and P1DT2H is 1 day and 2 hours.

What is the difference between Duration and Period in Java?

Duration is time-based (hours, minutes, seconds, and days as exactly 24 hours). Period is date-based (years, months, days). Duration.parse rejects years and months because they have no fixed length.

Why does Duration.toString() show PT24H and not P1D?

Java normalises a Duration to hours, minutes and seconds only. One day prints as PT24H.

Where are these used?

Spring configuration (spring.cache.redis.time-to-live=PT10M), Kubernetes, YouTube and calendar APIs, JSON schemas and OpenAPI.

More tools you might need