This package contains parsers implementations for reading Date, Time, DateTime, TimeZone, and ZoneDateTime values from their ISO 8601 formatted string representations.

The parser functions are parseDate(), parseTime(), parseDateTime(), parseTimeZone(), and parseZoneDateTime().

This package only contains parsers for reading Date, Time, DateTime and Period values from their string representation forms. There are no formatters in this package, as all relevant types return ISO 8601 formatted values as their string attribute.

If you need more flexible, locale aware parsing and formatting facilities, look into ceylon.locale package.

By: Roland Tepp
Functions
parseDateSource Codeshared Date? parseDate(String input)

The Date value of the given string representation of a ISO 8601 date format or null if the string does not contain valid ISO 8601 formatted date value or the date is not formatted according to ISO standard.

More specifically, this method parses any input that conforms to any of the following date formats:

  • YYYY-MM-DD or YYYYMMDD
  • YYYY-Www-D or YYYYWwwD
  • YYYY-DDD or YYYYDDD

Where: YYYY stands for a full (four digit) year number, MM is a number of a month of year (ranging from 01 for January to 12 for December), DD is a number of a day of month (ranging from 01 to 31), Www stands for a single uppercase character 'W' followed by two digit number of a week (ranging from 01 to 53) and D stands for a single digit day of week.

Note: This function accepts only four digit full year date formats. There is no support for abbreviated 2 digit format or year values larger than 4 digits.

parseDateTimeSource Codeshared DateTime? parseDateTime(String input)

The DateTime value of the given string representation of a ISO 8601 datetime format or null if the string does not contain valid ISO 8601 formatted datetime value or the datetime is not formatted according to ISO standard.

parsePeriodSource Codeshared Period? parsePeriod(String string)
parseTimeSource Codeshared Time? parseTime(String input)

The Time value of the given string representation of a ISO 8601 date format or null if the string does not contain valid ISO 8601 formatted date value or the date is not formatted according to ISO standard.

More specifically, this method parses any input that conforms to any of the following date formats:

  • hh:mm:ss.sss (or hhmmss.sss),
  • hh:mm:ss (or hhmmss),
  • hh:mm (or hhmm)
  • and hh

Where hh stands for 2 digit 24 hour clock hour value between 00 and 24 (where 24 is only used to denote midnight at the end of a calendar day)

parseTimeZoneSource Codeshared TimeZone? parseTimeZone(String offset)

Timezone offset parser based on ISO-8601, currently it accepts the following time zone offset patterns:

  • ±[hh]:[mm],
  • ±[hh][mm], and
  • ±[hh].

In addition, the special code Z is recognized as a shorthand for +00:00

parseZoneDateTimeSource Codeshared ZoneDateTime? parseZoneDateTime(String input)

The ZoneDateTime value of the given string representation of a ISO 8601 zoned datetime format or null if the string does not contain valid ISO 8601 formatted zoned datetime value or the datetime is not formatted according to ISO standard.