Class IsoDateTimeParser


  • public class IsoDateTimeParser
    extends Object
    Utility class for parsings ISO-8601 strings into java date time objects.
    • Method Detail

      • parseIsoDateTime

        public static ZonedDateTime parseIsoDateTime​(String isoDateTime)
        Converts an ISO 8601 Date or combined Date-Time String into a UTC based ZonedDateTime Object.

        No other time zones are supported, please provide your date-time in UTC with or without trailing "Z".

        Time zone designators in the form "+hh:mm" are not accepted.

        Examples:

          ISO Date: 2017
          ISO Date: 2016-03
          ISO Date: 2015-06-05
          Basic ISO Date: 20170305
          combined: 2011-10-03T20[Z]
          combined: 2011-10-03T20:15[Z]
          combined: 2011-10-03T20:15:25[Z]
          combined: 2011-10-03T20:15:25.123[Z]
         
        Parameters:
        isoDateTime - ISO Date or ISO DateTime string
        Returns:
        ZonedDateTime
        Throws:
        OSHDBTimestampException - if date or datetime pattern is not supported
        DateTimeException - if date or datetime cannot be parsed
      • parseIsoPeriod

        public static Map<String,​Object> parseIsoPeriod​(String isoPeriodString)
        Converts an ISO Period string into two parts, a period for the date part and a duration for the time part.

        Examples:

          ISO Date Period: P1Y (years)
          ISO Date Period: P3M (months)
          ISO Date Period: P1D (days)
          mixed ISO Dates:  P1Y25D or 1M15D
          ISO Date Period: P2W (weeks)
          ISO Time Duration: PT1H (hours)
          ISO Time Duration: PT30M (minutes)
          ISO Time Duration: PT20S (seconds)
          combined DateTime: P1Y3M5DT5H30M20S
         
        Parameters:
        isoPeriodString - ISO Period string
        Returns:
        HashMap with a Period object and a Duration object
        Throws:
        OSHDBTimeoutException - if the isoPeriodString is not valid