AlgoMaster Logo

Duration & Period

Medium Priority16 min readUpdated June 6, 2026

Time spans come in two flavors, and Java models them with two separate types. Duration measures machine time in seconds and nanoseconds, suited to cache TTLs, flash-sale countdowns, and SLA windows. Period measures calendar time in years, months, and days, suited to free-trial lengths, subscription terms, and return windows. This lesson covers both, then walks through the daylight saving time trap that exists precisely because they are not interchangeable.

Premium Content

Subscribe to unlock full access to this content and more premium articles.