Class IntervalFormatUtil


  • public class IntervalFormatUtil
    extends Object
    A simple formatter/parser utility for TemporalAmounts such as Duration and Period. Since there is much less variation in the possible display a simpler format is used than in other temporal formats. The format is denoted with a pattern string composed of various characters representing the amounts combined with optional literal characters. The characters that represent the various units are as follows. Y - Years M - Months W - Weeks D - Days H - Hours m - Minutes s - Seconds S - Milliseconds n - Nanoseconds Since intervals are represented as a collection of numeric values a single letter represents each quantity. Any of these may optionally be used as a literal character by escaping the character with a \. If any other characters are used in the format they are assumed to be literals. It is best to delimit each unit with a whitespace or literal to prevent parsing issues. The standard ISO format for Duration can be represented as \PD\D\TH\Hm\Ms.n\S in this format. The standard ISO format for Period can be represented as \PY\YM\MW\WD\D in this format.