Class ISO8601Utils

java.lang.Object
org.codehaus.jackson.map.util.ISO8601Utils

public class ISO8601Utils extends Object
Utilities methods for manipulating dates in iso8601 format. This is much much faster and GC friendly than using SimpleDateFormat so highly suitable if you (un)serialize lots of date objects.
  • Constructor Details

    • ISO8601Utils

      public ISO8601Utils()
  • Method Details

    • format

      public static String format(Date date)
      Format a date into 'yyyy-MM-ddThh:mm:ssZ' (GMT timezone, no milliseconds precision)
      Parameters:
      date - the date to format
      Returns:
      the date formatted as 'yyyy-MM-ddThh:mm:ssZ'
    • format

      public static String format(Date date, boolean millis)
      Format a date into 'yyyy-MM-ddThh:mm:ss[.sss]Z' (GMT timezone)
      Parameters:
      date - the date to format
      millis - true to include millis precision otherwise false
      Returns:
      the date formatted as 'yyyy-MM-ddThh:mm:ss[.sss]Z'
    • format

      public static String format(Date date, boolean millis, TimeZone tz)
      Format date into yyyy-MM-ddThh:mm:ss[.sss][Z|[+-]hh:mm]
      Parameters:
      date - the date to format
      millis - true to include millis precision otherwise false
      tz - timezone to use for the formatting (GMT will produce 'Z')
      Returns:
      the date formatted as yyyy-MM-ddThh:mm:ss[.sss][Z|[+-]hh:mm]
    • parse

      public static Date parse(String date)
      Parse a date from ISO-8601 formatted string. It expects a format yyyy-MM-ddThh:mm:ss[.sss][Z|[+-]hh:mm]
      Parameters:
      date - ISO string to parse in the appropriate format.
      Returns:
      the parsed date
      Throws:
      IllegalArgumentException - if the date is not in the appropriate format