Class Iso8601Format
Collection of predefined format objects for ISO-8601.
All formatters are strict by default. The preferred decimal separator is the comma during printing. This configuration follows the official recommendation of ISO-8601. However, if the system property "net.time4j.format.iso.decimal.dot" is set to "true" then the dot will be used. When parsing, both comma or dot are understood.
Note: Most produced formatters ignore any format attribute change. As exception case, timezone
attributes are recognized by BASIC_DATE_TIME_OFFSET
or EXTENDED_DATE_TIME_OFFSET
.
- Author:
- Meno Hochschild
-
Field Summary
Modifier and TypeFieldDescriptionstatic ChronoFormatter<PlainDate>
Defines the basic ISO-8601-format with year, month and day of month using the pattern "uuuuMMdd".static ChronoFormatter<PlainDate>
Similar toBASIC_CALENDAR_DATE
but its parser can also understand ordinal dates or week dates.static ChronoFormatter<PlainTimestamp>
Defines the basic ISO-8601-format for a composition of calendar date and wall time with hour and minute using the pattern "uuuuMMdd'T'HH[mm[ss[,SSSSSSSSS]]]".static ChronoFormatter<Moment>
Defines the basic ISO-8601-format for a composition of calendar date, wall time and timezone offset using the pattern "uuuuMMdd'T'HH[mm[ss[,SSSSSSSSS]]]{offset}".static ChronoFormatter<PlainDate>
Defines the basic ISO-8601-format with year and day of year using the pattern "uuuuDDD".static ChronoFormatter<PlainTime>
Defines the basic ISO-8601-format for a wall time with hour, minute and optional second using the pattern "HH[mm[ss[,SSSSSSSSS]]]".static ChronoFormatter<PlainDate>
Defines the basic ISO-8601-format for a week date using the pattern "YYYYWwwE".static ChronoFormatter<PlainDate>
Defines the extended ISO-8601-format with year, month and day of month using the pattern "uuuu-MM-dd".static ChronoFormatter<PlainDate>
Similar toEXTENDED_CALENDAR_DATE
but its parser can also understand ordinal dates or week dates.static ChronoFormatter<PlainTimestamp>
Defines the extended ISO-8601-format for a composition of calendar date and wall time with hour and minute using the pattern "uuuu-MM-dd'T'HH[:mm[:ss[,SSSSSSSSS]]]".static ChronoFormatter<Moment>
Defines the extended ISO-8601-format for a composition of calendar date, wall time and timezone offset using the pattern "uuuu-MM-dd'T'HH[:mm[:ss[,SSSSSSSSS]]]{offset}".static ChronoFormatter<PlainDate>
Defines the extended ISO-8601-format with year and day of year using the pattern "uuuu-DDD".static ChronoFormatter<PlainTime>
Defines the extended ISO-8601-format for a wall time with hour, minute and optional second using the pattern "HH[:mm[:ss[,SSSSSSSSS]]]".static ChronoFormatter<PlainDate>
Defines the extended ISO-8601-format for a week date using the pattern "YYYY-Www-E". -
Method Summary
Modifier and TypeMethodDescriptionstatic ChronoPrinter<PlainTime>
ofBasicTime(IsoDecimalStyle decimalStyle, ClockUnit precision)
Obtains a printer with given decimal style for printing a clock time in basic format "HHmm[ss[,SSSSSSSSS]]".static ChronoPrinter<PlainDate>
ofDate(IsoDateStyle style)
Obtains a printer with given styles for printing a calendar date.static ChronoPrinter<PlainTime>
ofExtendedTime(IsoDecimalStyle decimalStyle, ClockUnit precision)
Obtains a printer with given decimal style for printing a clock time in extended format "HH:mm[:ss[,SSSSSSSSS]]".static ChronoPrinter<Moment>
ofMoment(IsoDateStyle dateStyle, IsoDecimalStyle decimalStyle, ClockUnit precision, ZonalOffset offset)
Obtains a printer with given styles for printing a moment.static ChronoPrinter<PlainTimestamp>
ofTimestamp(IsoDateStyle dateStyle, IsoDecimalStyle decimalStyle, ClockUnit precision)
Obtains a printer with given styles for printing a timestamp.static PlainDate
parseDate(CharSequence iso)
Parses given ISO-8601-compatible date string in basic or extended format.static PlainDate
parseDate(CharSequence iso, ParseLog plog)
Parses given ISO-8601-compatible date string in basic or extended format.
-
Field Details
-
BASIC_CALENDAR_DATE
Defines the basic ISO-8601-format with year, month and day of month using the pattern "uuuuMMdd".
-
EXTENDED_CALENDAR_DATE
Defines the extended ISO-8601-format with year, month and day of month using the pattern "uuuu-MM-dd".
-
BASIC_ORDINAL_DATE
Defines the basic ISO-8601-format with year and day of year using the pattern "uuuuDDD".
-
EXTENDED_ORDINAL_DATE
Defines the extended ISO-8601-format with year and day of year using the pattern "uuuu-DDD".
-
BASIC_WEEK_DATE
Defines the basic ISO-8601-format for a week date using the pattern "YYYYWwwE".
-
EXTENDED_WEEK_DATE
Defines the extended ISO-8601-format for a week date using the pattern "YYYY-Www-E".
-
BASIC_DATE
Similar to
BASIC_CALENDAR_DATE
but its parser can also understand ordinal dates or week dates.- Since:
- 3.22/4.18
-
EXTENDED_DATE
Similar to
EXTENDED_CALENDAR_DATE
but its parser can also understand ordinal dates or week dates.- Since:
- 3.22/4.18
-
BASIC_WALL_TIME
Defines the basic ISO-8601-format for a wall time with hour, minute and optional second using the pattern "HH[mm[ss[,SSSSSSSSS]]]".
The minute part is optional during parsing, but will always be printed. The parser also accepts a leading char T.
-
EXTENDED_WALL_TIME
Defines the extended ISO-8601-format for a wall time with hour, minute and optional second using the pattern "HH[:mm[:ss[,SSSSSSSSS]]]".
The minute part is optional during parsing, but will always be printed. The parser also accepts a leading char T.
-
BASIC_DATE_TIME
Defines the basic ISO-8601-format for a composition of calendar date and wall time with hour and minute using the pattern "uuuuMMdd'T'HH[mm[ss[,SSSSSSSSS]]]".
Second and nanosecond elements are optional. Furthermore, the count of decimal digits is flexible (0-9). The minute part is optional during parsing, but will always be printed. The parser will also understand a combination of ordinal date or week date together with the wall time.
-
EXTENDED_DATE_TIME
Defines the extended ISO-8601-format for a composition of calendar date and wall time with hour and minute using the pattern "uuuu-MM-dd'T'HH[:mm[:ss[,SSSSSSSSS]]]".
Second and nanosecond elements are optional. Furthermore, the count of decimal digits is flexible (0-9). The minute part is optional during parsing, but will always be printed. The parser will also understand a combination of ordinal date or week date together with the wall time.
-
BASIC_DATE_TIME_OFFSET
Defines the basic ISO-8601-format for a composition of calendar date, wall time and timezone offset using the pattern "uuuuMMdd'T'HH[mm[ss[,SSSSSSSSS]]]{offset}".
Second and nanosecond elements are optional. Furthermore, the count of decimal digits is flexible (0-9). The minute part is optional during parsing, but will always be printed. The offset part is for printing equivalent to XX, for parsing equivalent to X. The parser will also understand a combination of ordinal date or week date together with the wall time.
By default, the timezone offset used for printing is UTC+00:00. Users can override this offset by calling the method
ChronoFormatter.withTimezone(net.time4j.tz.TZID)
. -
EXTENDED_DATE_TIME_OFFSET
Defines the extended ISO-8601-format for a composition of calendar date, wall time and timezone offset using the pattern "uuuu-MM-dd'T'HH[:mm[:ss[,SSSSSSSSS]]]{offset}".
Second and nanosecond elements are optional. Furthermore, the count of decimal digits is flexible (0-9). The minute part is optional during parsing, but will always be printed. The offset part is for printing equivalent to XXX, for parsing equivalent to X (but with colon!). The parser will also understand a combination of ordinal date or week date together with the wall time.
By default, the timezone offset used for printing is UTC+00:00. Users can override this offset by calling the method
ChronoFormatter.withTimezone(net.time4j.tz.TZID)
.
-
-
Method Details
-
ofDate
Obtains a printer with given styles for printing a calendar date.
- Parameters:
style
- iso-compatible date style- Returns:
- ChronoPrinter
- Since:
- 4.18
-
ofBasicTime
public static ChronoPrinter<PlainTime> ofBasicTime(IsoDecimalStyle decimalStyle, ClockUnit precision)Obtains a printer with given decimal style for printing a clock time in basic format "HHmm[ss[,SSSSSSSSS]]".
It is recommended to store the result in a static final constant for achieving best performance.
- Parameters:
decimalStyle
- iso-compatible decimal styleprecision
- controls the precision of output format with constant length- Returns:
- ChronoPrinter as new instance
- Since:
- 4.18
-
ofExtendedTime
public static ChronoPrinter<PlainTime> ofExtendedTime(IsoDecimalStyle decimalStyle, ClockUnit precision)Obtains a printer with given decimal style for printing a clock time in extended format "HH:mm[:ss[,SSSSSSSSS]]".
It is recommended to store the result in a static final constant for achieving best performance.
- Parameters:
decimalStyle
- iso-compatible decimal styleprecision
- controls the precision of output format with constant length- Returns:
- ChronoPrinter as new instance
- Since:
- 4.18
-
ofTimestamp
public static ChronoPrinter<PlainTimestamp> ofTimestamp(IsoDateStyle dateStyle, IsoDecimalStyle decimalStyle, ClockUnit precision)Obtains a printer with given styles for printing a timestamp.
It is recommended to store the result in a static final constant for achieving best performance.
- Parameters:
dateStyle
- iso-compatible date styledecimalStyle
- iso-compatible decimal styleprecision
- controls the precision of output format with constant length- Returns:
- ChronoPrinter as new instance
- Since:
- 4.18
-
ofMoment
public static ChronoPrinter<Moment> ofMoment(IsoDateStyle dateStyle, IsoDecimalStyle decimalStyle, ClockUnit precision, ZonalOffset offset)Obtains a printer with given styles for printing a moment.
It is recommended to store the result in a static final constant for achieving best performance.
- Parameters:
dateStyle
- iso-compatible date styledecimalStyle
- iso-compatible decimal styleprecision
- controls the precision of output format with constant lengthoffset
- time zone offset- Returns:
- ChronoPrinter as new instance
- Since:
- 4.18
-
parseDate
Parses given ISO-8601-compatible date string in basic or extended format.
- Parameters:
iso
- text like "20160101", "2016001", "2016W011", "2016-01-01", "2016-001" or "2016-W01-1"- Returns:
- PlainDate
- Throws:
ParseException
- if parsing fails for any reason- Since:
- 3.22/4.18
-
parseDate
Parses given ISO-8601-compatible date string in basic or extended format.
- Parameters:
iso
- text like "20160101", "2016001", "2016W011", "2016-01-01", "2016-001" or "2016-W01-1"plog
- new mutable instance ofParseLog
- Returns:
- PlainDate or
null
in case of error - Throws:
IndexOutOfBoundsException
- if the start position is at end of text or even behind- Since:
- 3.22/4.18
- See Also:
ParseLog.isError()
-