This class does not support methods that influence the format. It always formats the date based on the specification below.
3.3. Date and Time Specification
Date and time occur in several header fields. This section specifies the syntax for a full date and time specification. Though folding white space is permitted throughout the date-time specification, it is RECOMMENDED that a single space be used in each place that FWS appears (whether it is required or optional); some older implementations may not interpret other occurrences of folding white space correctly.
date-time = [ day-of-week "," ] date FWS time [CFWS]
day-of-week = ([FWS] day-name) / obs-day-of-week
day-name = "Mon" / "Tue" / "Wed" / "Thu" /
"Fri" / "Sat" / "Sun"
date = day month year
year = 4*DIGIT / obs-year
month = (FWS month-name FWS) / obs-month
month-name = "Jan" / "Feb" / "Mar" / "Apr" /
"May" / "Jun" / "Jul" / "Aug" /
"Sep" / "Oct" / "Nov" / "Dec"
day = ([FWS] 1*2DIGIT) / obs-day
time = time-of-day FWS zone
time-of-day = hour ":" minute [ ":" second ]
hour = 2DIGIT / obs-hour
minute = 2DIGIT / obs-minute
second = 2DIGIT / obs-second
zone = (( "+" / "-" ) 4DIGIT) / obs-zone
The day is the numeric day of the month. The year is any numeric year
1900 or later.
The time-of-day specifies the number of hours, minutes, and optionally seconds since midnight of the date indicated.
The date and time-of-day SHOULD express local time.
The zone specifies the offset from Coordinated Universal Time (UTC, formerly referred to as "Greenwich Mean Time") that the date and time-of-day represent. The "+" or "-" indicates whether the time-of-day is ahead of (i.e., east of) or behind (i.e., west of) Universal Time. The first two digits indicate the number of hours difference from Universal Time, and the last two digits indicate the number of minutes difference from Universal Time. (Hence, +hhmm means +(hh * 60 + mm) minutes, and -hhmm means -(hh * 60 + mm) minutes). The form "+0000" SHOULD be used to indicate a time zone at Universal Time. Though "-0000" also indicates Universal Time, it is used to indicate that the time was generated on a system that may be in a local time zone other than Universal Time and therefore indicates that the date-time contains no information about the local time zone.
A date-time specification MUST be semantically valid. That is, the day-of-the-week (if included) MUST be the day implied by the date, the numeric day-of-month MUST be between 1 and the number of days allowed for the specified month (in the specified year), the time-of-day MUST be in the range 00:00:00 through 23:59:60 (the number of seconds allowing for a leap second; see [STD12]), and the zone MUST be within the range -9959 through +9959.
Date formats are not synchronized. It is recommended to create separate format instances for each thread. If multiple threads access a format concurrently, it must be synchronized externally.
| Modifier and Type | Class and Description |
|---|---|
| private abstract static class | MailDateFormat.AbstractDateParser
This class provides the building blocks for date parsing. |
| private class | |
| private class |
| Modifier and Type | Field and Description |
|---|---|
| private static final int | |
| private static final MailLogger | |
| private static final String | |
| private static final long | |
| private static final int | |
| private static final TimeZone |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | applyLocalizedPattern(String
a String to be mapped to the new date and time format
pattern for this format pattern)
This method always throws an UnsupportedOperationException and should not
be used because RFC 2822 mandates a specific pattern.
|
| public void | applyPattern(String
the new date and time pattern for this date format pattern)Overrides java. |
| public MailDateFormat | Returns: a clone of this instanceOverrides java. |
| public StringBuffer | Returns: StringBuffer the formatted Stringthe Date object date, StringBuffer the formatted string dateStrBuf, FieldPosition the current field position fieldPosition)Overrides java. |
| public Date | Returns: the start of the 100-year period into which two digit years are parsed |
| public Date | Returns: Date the parsed date. In case of error, returns null.the formatted date to be parsed text, ParsePosition the current parse position pos)Overrides java. |
| private void | readObject(ObjectInputStream
the stream containing the serialized object in)
Allows to deserialize instances that were serialized with the previous
implementation.
|
| public void | set2DigitYearStart(Date
During parsing, two digit years will be placed in the range
startDate)
This method always throws an UnsupportedOperationException and should not
be used because RFC 2822 mandates another strategy for interpreting
2-digits years.
startDate to startDate + 100 years. |
| public void | setCalendar(Calendar
the new newCalendar)Calendar to be used by the date formatOverrides java. |
| public void | setDateFormatSymbols(DateFormatSymbols
the new date and time format symbols newFormatSymbols)
This method always throws an UnsupportedOperationException and should not
be used because RFC 2822 mandates specific date format symbols.
|
| public void | setNumberFormat(NumberFormat
the given new NumberFormat. newNumberFormat)Overrides java. |
| private void | |
| private Date | Returns: the date, as specified by the parametersReturns the date, as specified by the parameters. |
| private Object | Returns: the object to be serializedAllows to serialize instances such that they are deserializable with the previous implementation. |
| LEAP_SECOND | back to summary |
|---|---|
| private static final int LEAP_SECOND | |
| LOGGER | back to summary |
|---|---|
| private static final MailLogger LOGGER | |
| PATTERN | back to summary |
|---|---|
| private static final String PATTERN | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID | |
| UNKNOWN_DAY_NAME | back to summary |
|---|---|
| private static final int UNKNOWN_DAY_NAME | |
| UTC | back to summary |
|---|---|
| private static final TimeZone UTC | |
| MailDateFormat | back to summary |
|---|---|
| public MailDateFormat() Create a new date format for the RFC2822 specification with lenient parsing. | |
| applyLocalizedPattern | back to summary |
|---|---|
| public void applyLocalizedPattern(String pattern) Overrides java. This method always throws an UnsupportedOperationException and should not be used because RFC 2822 mandates a specific pattern.
| |
| applyPattern | back to summary |
|---|---|
| public void applyPattern(String pattern) Overrides java. This method always throws an UnsupportedOperationException and should not be used because RFC 2822 mandates a specific pattern.
| |
| clone | back to summary |
|---|---|
| public MailDateFormat clone() Overrides java. Overrides Cloneable.
| |
| format | back to summary |
|---|---|
| public StringBuffer format(Date date, StringBuffer dateStrBuf, FieldPosition fieldPosition) Overrides java. Formats the given date in the format specified by RFC 2822 in the current TimeZone.
| |
| get2DigitYearStart | back to summary |
|---|---|
| public Date get2DigitYearStart() Overrides java. This method always throws an UnsupportedOperationException and should not be used because RFC 2822 mandates another strategy for interpreting 2-digits years.
| |
| parse | back to summary |
|---|---|
| public Date parse(String text, ParsePosition pos) Overrides java. Parses the given date in the format specified by RFC 2822.
| |
| readObject | back to summary |
|---|---|
| private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException Hides java. Allows to deserialize instances that were serialized with the previous implementation.
| |
| set2DigitYearStart | back to summary |
|---|---|
| public void set2DigitYearStart(Date startDate) Overrides java. This method always throws an UnsupportedOperationException and should not be used because RFC 2822 mandates another strategy for interpreting 2-digits years.
| |
| setCalendar | back to summary |
|---|---|
| public void setCalendar(Calendar newCalendar) Overrides java. This method always throws an UnsupportedOperationException and should not be used because RFC 2822 mandates a specific calendar.
| |
| setDateFormatSymbols | back to summary |
|---|---|
| public void setDateFormatSymbols(DateFormatSymbols newFormatSymbols) Overrides java. This method always throws an UnsupportedOperationException and should not be used because RFC 2822 mandates specific date format symbols.
| |
| setNumberFormat | back to summary |
|---|---|
| public void setNumberFormat(NumberFormat newNumberFormat) Overrides java. This method always throws an UnsupportedOperationException and should not be used because RFC 2822 mandates a specific number format.
| |
| superApplyPattern | back to summary |
|---|---|
| private void superApplyPattern(String pattern) This method allows serialization to change the pattern. | |
| toDate | back to summary |
|---|---|
| private Date toDate(int dayName, int day, int month, int year, int hour, int minute, int second, int zone) Returns the date, as specified by the parameters.
| |
| writeReplace | back to summary |
|---|---|
| private Object writeReplace() throws ObjectStreamException Allows to serialize instances such that they are deserializable with the previous implementation.
| |
It has the following invariants:
| Modifier and Type | Field and Description |
|---|---|
| pack-priv static final int | |
| pack-priv static final int | |
| pack-priv final ParsePosition | |
| pack-priv final String |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv final int | |
| pack-priv final int | |
| pack-priv boolean | |
| pack-priv final Date | |
| pack-priv final int | |
| pack-priv final int | |
| pack-priv final int | |
| pack-priv final void | |
| pack-priv final int | |
| pack-priv final void | |
| pack-priv final int | Returns: the java.util.Calendar constant for the parsed month name
|
| pack-priv final int | Returns: the number of minutes to be added to the time in the local time zone, in order to obtain the equivalent time in the UTC time zone. Returns 0 if the date-time contains no information about the local time zone.
|
| pack-priv final boolean | |
| pack-priv final boolean | |
| pack-priv boolean | |
| pack-priv final boolean | |
| pack-priv final boolean | skipAlternativePair(char firstStandard, char firstAlternative, char secondStandard, char secondAlternative)
|
| pack-priv final boolean | skipAlternativeTriple(char firstStandard, char firstAlternative, char secondStandard, char secondAlternative, char thirdStandard, char thirdAlternative)
|
| pack-priv final boolean | |
| pack-priv boolean | |
| pack-priv final boolean | |
| pack-priv final boolean | |
| pack-priv final boolean | |
| pack-priv abstract Date |
| INVALID_CHAR | back to summary |
|---|---|
| pack-priv static final int INVALID_CHAR | |
| MAX_YEAR_DIGITS | back to summary |
|---|---|
| pack-priv static final int MAX_YEAR_DIGITS | |
| pos | back to summary |
|---|---|
| pack-priv final ParsePosition pos | |
| text | back to summary |
|---|---|
| pack-priv final String text | |
| AbstractDateParser | back to summary |
|---|---|
| pack-priv AbstractDateParser(String text, ParsePosition pos) | |
| getAsciiDigit | back to summary |
|---|---|
| pack-priv final int getAsciiDigit() | |
| getChar | back to summary |
|---|---|
| pack-priv final int getChar() | |
| isValidZoneOffset | back to summary |
|---|---|
| pack-priv boolean isValidZoneOffset(int offset) | |
| parse | back to summary |
|---|---|
| pack-priv final Date parse() | |
| parseAsciiDigits | back to summary |
|---|---|
| pack-priv final int parseAsciiDigits(int count) throws ParseException | |
| parseAsciiDigits | back to summary |
|---|---|
| pack-priv final int parseAsciiDigits(int min, int max) throws ParseException | |
| parseAsciiDigits | back to summary |
|---|---|
| pack-priv final int parseAsciiDigits(int min, int max, boolean isEOF) throws ParseException | |
| parseChar | back to summary |
|---|---|
| pack-priv final void parseChar(char ch) throws ParseException | |
| parseDayName | back to summary |
|---|---|
pack-priv final int parseDayName() throws ParseException
| |
| parseFoldingWhiteSpace | back to summary |
|---|---|
| pack-priv final void parseFoldingWhiteSpace() throws ParseException | |
| parseMonthName | back to summary |
|---|---|
pack-priv final int parseMonthName(boolean caseSensitive) throws ParseException
| |
| parseZoneOffset | back to summary |
|---|---|
pack-priv final int parseZoneOffset() throws ParseException
| |
| peekAsciiDigit | back to summary |
|---|---|
| pack-priv final boolean peekAsciiDigit() | |
| peekChar | back to summary |
|---|---|
| pack-priv final boolean peekChar(char ch) | |
| peekFoldingWhiteSpace | back to summary |
|---|---|
| pack-priv boolean peekFoldingWhiteSpace() | |
| skipAlternative | back to summary |
|---|---|
| pack-priv final boolean skipAlternative(char standard, char alternative) | |
| skipAlternativePair | back to summary |
|---|---|
| pack-priv final boolean skipAlternativePair(char firstStandard, char firstAlternative, char secondStandard, char secondAlternative) | |
| skipAlternativeTriple | back to summary |
|---|---|
| pack-priv final boolean skipAlternativeTriple(char firstStandard, char firstAlternative, char secondStandard, char secondAlternative, char thirdStandard, char thirdAlternative) | |
| skipChar | back to summary |
|---|---|
| pack-priv final boolean skipChar(char ch) | |
| skipFoldingWhiteSpace | back to summary |
|---|---|
| pack-priv boolean skipFoldingWhiteSpace() | |
| skipNewline | back to summary |
|---|---|
| pack-priv final boolean skipNewline() | |
| skipPair | back to summary |
|---|---|
| pack-priv final boolean skipPair(char first, char second) | |
| skipWhiteSpace | back to summary |
|---|---|
| pack-priv final boolean skipWhiteSpace() | |
| tryParse | back to summary |
|---|---|
| pack-priv abstract Date tryParse() throws ParseException | |
| Modifier and Type | Field and Description |
|---|---|
| private Boolean |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv boolean | |
| pack-priv boolean | isValidZoneOffset(int offset)
Overrides javax. |
| pack-priv int | |
| pack-priv void | |
| pack-priv void | |
| pack-priv int | |
| pack-priv int | |
| pack-priv int | |
| pack-priv int | |
| pack-priv int | |
| pack-priv int | |
| pack-priv boolean | |
| pack-priv boolean |
| hasDefaultFws | back to summary |
|---|---|
| private Boolean hasDefaultFws | |
| Rfc2822LenientParser | back to summary |
|---|---|
| pack-priv Rfc2822LenientParser(String text, ParsePosition pos) | |
| isMonthNameCaseSensitive | back to summary |
|---|---|
| pack-priv boolean isMonthNameCaseSensitive() Overrides javax.
| |
| isValidZoneOffset | back to summary |
|---|---|
| pack-priv boolean isValidZoneOffset(int offset) Overrides javax.
| |
| parseDay | back to summary |
|---|---|
| pack-priv int parseDay() throws ParseException Overrides javax.
| |
| parseFwsBetweenTimeOfDayAndZone | back to summary |
|---|---|
| pack-priv void parseFwsBetweenTimeOfDayAndZone() throws ParseException Overrides javax.
| |
| parseFwsInMonth | back to summary |
|---|---|
| pack-priv void parseFwsInMonth() throws ParseException Overrides javax.
| |
| parseHour | back to summary |
|---|---|
| pack-priv int parseHour() throws ParseException Overrides javax.
| |
| parseMinute | back to summary |
|---|---|
| pack-priv int parseMinute() throws ParseException Overrides javax.
| |
| parseOptionalBegin | back to summary |
|---|---|
| pack-priv int parseOptionalBegin() Overrides javax.
| |
| parseSecond | back to summary |
|---|---|
| pack-priv int parseSecond() throws ParseException Overrides javax.
| |
| parseYear | back to summary |
|---|---|
| pack-priv int parseYear() throws ParseException Overrides javax.
| |
| parseZone | back to summary |
|---|---|
| pack-priv int parseZone() throws ParseException Overrides javax.
| |
| peekFoldingWhiteSpace | back to summary |
|---|---|
| pack-priv boolean peekFoldingWhiteSpace() Overrides javax.
| |
| skipFoldingWhiteSpace | back to summary |
|---|---|
| pack-priv boolean skipFoldingWhiteSpace() Overrides javax.
| |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv boolean | |
| pack-priv int | |
| pack-priv void | |
| pack-priv void | |
| pack-priv int | |
| pack-priv int | |
| pack-priv int | |
| pack-priv int | Returns: the java.util.Calendar constant for the parsed day name, or UNKNOWN_DAY_NAME iff the begin is missing
|
| pack-priv int | |
| pack-priv int | |
| pack-priv int | |
| pack-priv Date |
| Rfc2822StrictParser | back to summary |
|---|---|
| pack-priv Rfc2822StrictParser(String text, ParsePosition pos) | |
| isMonthNameCaseSensitive | back to summary |
|---|---|
| pack-priv boolean isMonthNameCaseSensitive() | |
| parseDay | back to summary |
|---|---|
| pack-priv int parseDay() throws ParseException | |
| parseFwsBetweenTimeOfDayAndZone | back to summary |
|---|---|
| pack-priv void parseFwsBetweenTimeOfDayAndZone() throws ParseException | |
| parseFwsInMonth | back to summary |
|---|---|
| pack-priv void parseFwsInMonth() throws ParseException | |
| parseHour | back to summary |
|---|---|
| pack-priv int parseHour() throws ParseException | |
| parseMinute | back to summary |
|---|---|
| pack-priv int parseMinute() throws ParseException | |
| parseMonth | back to summary |
|---|---|
pack-priv int parseMonth() throws ParseException
| |
| parseOptionalBegin | back to summary |
|---|---|
pack-priv int parseOptionalBegin() throws ParseException
| |
| parseSecond | back to summary |
|---|---|
| pack-priv int parseSecond() throws ParseException | |
| parseYear | back to summary |
|---|---|
| pack-priv int parseYear() throws ParseException | |
| parseZone | back to summary |
|---|---|
| pack-priv int parseZone() throws ParseException | |
| tryParse | back to summary |
|---|---|
| pack-priv Date tryParse() throws ParseException Implements abstract javax.
| |