Class DateEncoder

java.lang.Object
org.dellroad.stuff.string.DateEncoder

public final class DateEncoder extends Object
Encodes Date objects to and from strings.
  • Field Details

  • Method Details

    • encode

      public static String encode(Date date)
      Encode the given date as a string of the form 2009-12-01T15:33:07.763Z. If the fractional seconds portion is zero, it will be omitted.
      Parameters:
      date - date to encode
      Returns:
      endoded date
      Throws:
      NullPointerException - if date is null
    • decode

      public static Date decode(String string)
      Decode the given date.
      Parameters:
      string - encoded date
      Returns:
      decoded date
      Throws:
      IllegalArgumentException - if string is malformed
      NullPointerException - if string is null
    • getDateFormat

      public static SimpleDateFormat getDateFormat(String format)
      Get a SimpleDateFormat configured with the given format and for the UTC time zone and strict parsing.
      Parameters:
      format - date format string
      Returns:
      date formatter