java.lang.Object
com.sun.syndication.io.impl.DateParser
- public class DateParser
- extends java.lang.Object
A helper class that parses Dates out of Strings with date time in RFC822 and W3CDateTime
formats plus the variants Atom (0.3) and RSS (0.9, 0.91, 0.92, 0.93, 0.94, 1.0 and 2.0)
specificators added to those formats.
It uses the JDK java.text.SimpleDateFormat class attemtping the parse using a mask for
each one of the possible formats.
|
Constructor Summary |
private |
DateParser()
Private constructor to avoid DateParser instances creation. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ADDITIONAL_MASKS
private static java.lang.String[] ADDITIONAL_MASKS
RFC822_MASKS
private static final java.lang.String[] RFC822_MASKS
W3CDATETIME_MASKS
private static final java.lang.String[] W3CDATETIME_MASKS
DateParser
private DateParser()
- Private constructor to avoid DateParser instances creation.
parseUsingMask
private static java.util.Date parseUsingMask(java.lang.String[] masks,
java.lang.String sDate)
- Parses a Date out of a string using an array of masks.
It uses the masks in order until one of them succedes or all fail.
parseRFC822
public static java.util.Date parseRFC822(java.lang.String sDate)
- Parses a Date out of a String with a date in RFC822 format.
It parsers the following formats:
- "EEE, dd MMM yyyy HH:mm:ss z"
- "EEE, dd MMM yyyy HH:mm z"
- "EEE, dd MMM yy HH:mm:ss z"
- "EEE, dd MMM yy HH:mm z"
- "dd MMM yyyy HH:mm:ss z"
- "dd MMM yyyy HH:mm z"
- "dd MMM yy HH:mm:ss z"
- "dd MMM yy HH:mm z"
Refer to the java.text.SimpleDateFormat javadocs for details on the format of each element.
parseW3CDateTime
public static java.util.Date parseW3CDateTime(java.lang.String sDate)
- Parses a Date out of a String with a date in W3C date-time format.
It parsers the following formats:
- "yyyy-MM-dd'T'HH:mm:ssz"
- "yyyy-MM-dd'T'HH:mmz"
- "yyyy-MM-dd"
- "yyyy-MM"
- "yyyy"
Refer to the java.text.SimpleDateFormat javadocs for details on the format of each element.
parseDate
public static java.util.Date parseDate(java.lang.String sDate)
- Parses a Date out of a String with a date in W3C date-time format or
in a RFC822 format.
formatRFC822
public static java.lang.String formatRFC822(java.util.Date date)
- create a RFC822 representation of a date.
Refer to the java.text.SimpleDateFormat javadocs for details on the format of each element.
formatW3CDateTime
public static java.lang.String formatW3CDateTime(java.util.Date date)
- create a W3C Date Time representation of a date.
Refer to the java.text.SimpleDateFormat javadocs for details on the format of each element.