Class ISO8601Calendar

java.lang.Object
java.util.Calendar
java.util.GregorianCalendar
de.stefanfrings.utils.ISO8601Calendar
All Implemented Interfaces:
Serializable, Cloneable, Comparable<Calendar>

public class ISO8601Calendar extends GregorianCalendar
ISO 8601 date/time encoder and decoder.
Author:
Stefan Frings, http://stefanfrings.de/javautils
See Also:
  • Constructor Details

    • ISO8601Calendar

      public ISO8601Calendar(Date date, TimeZone tz)
      Constructor, sets the internal value to the given date/time.
      Parameters:
      date - Date
      tz - optional timezone, default if UTC.
    • ISO8601Calendar

      public ISO8601Calendar(String isodate) throws NumberFormatException
      Constructor, parses date string.

      The String format may be one of

      • YYYY-MM-DDThh:mm:ss.sZ (UTC, timetone offset = 0)
      • YYYY-MM-DDThh:mm:ss.s+hh:mm
      • YYYY-MM-DDThh:mm:ss.s-hh:mm

      Parts from the right side (e.g. the whole time or the seconds) can be left out.

      Parameters:
      isodate - Date string in ISO 8601 format.
      Throws:
      NumberFormatException - If the date format is invalid.
  • Method Details

    • toString

      public String toString()
      Return the internal value as ISO 8601 date string in format YYYY-MM-DDThh:mm:ss.s+hh:mm
      Overrides:
      toString in class Calendar
      Returns:
      a string representing the date