Class DateParser

java.lang.Object
com.attribyte.parser.DateParser

public class DateParser extends Object
Date/time parsing methods.
Author:
Matt Hamer.
  • Field Details

    • ISO8601_FORMATTER

      public static final org.joda.time.format.DateTimeFormatter ISO8601_FORMATTER
      The ISO 8601 formatter.
  • Constructor Details

    • DateParser

      public DateParser()
  • Method Details

    • parseISO8601

      public static long parseISO8601(String dateTimeStr) throws ParseException
      Parses a date/time in ISO8601 format.
      Parameters:
      dateTimeStr - The string.
      Returns:
      The timestamp.
      Throws:
      ParseException - on invalid format.
    • tryParseISO8601

      public static Long tryParseISO8601(String dateTimeStr)
      Try to parse date/time in ISO8601 format.
      Parameters:
      dateTimeStr - The string.
      Returns:
      The timestamp or null if invalid.
    • tryParseRFC822

      public static Long tryParseRFC822(String dateTimeStr)
      Try to parse date/time in ISO8601 format.
      Parameters:
      dateTimeStr - The string.
      Returns:
      The timestamp or null if invalid.
    • parseRFC822

      public static final long parseRFC822(String dateTimeStr) throws ParseException
      Lenient parse RFC822.

      Some examples... Wed, 02 Oct 2002 08:00:00 EST Wed, 02 Oct 2002 13:00:00 GMT Wed, 02 Oct 2002 15:00:00 +0200 Tue, 17 Jul 2012 19:56:08 +0000

      Parameters:
      dateTimeStr - The date/time string.
      Returns:
      The timestamp.
      Throws:
      ParseException - on invalid format.
    • getTimestampMillis

      public static final long getTimestampMillis(int year, int month, int day, int hour, int min, int sec)
      Gets the timestamp in millis given year, month, etc...
      Parameters:
      year - The year.
      month - The month (1 == Jan)
      day - The day of the month.
      hour - The hour.
      min - The minute.
      sec - The second.
      Returns:
      The timestamp.