Class DateFormatter
java.lang.Object
io.netty.handler.codec.DateFormatter
A formatter for HTTP header dates, such as "Expires" and "Date" headers, or "expires" field in "Set-Cookie".
On the parsing side, it honors RFC6265 (so it supports RFC1123).
Note that:
- Day of week is ignored and not validated
- Timezone is ignored, as RFC6265 assumes UTC
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final GregorianCalendarprivate static final String[]private static final String[]private intprivate booleanprivate static final BitSetprivate intprivate static final FastThreadLocal<DateFormatter> private intprivate intprivate booleanprivate final StringBuilderprivate intprivate booleanprivate intprivate boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringBuilderappend(Date date, StringBuilder sb) Append aDateto aStringBuilderinto RFC1123 formatprivate StringBuilderappend0(Date date, StringBuilder sb) private static StringBuilderappendZeroLeftPadded(int value, StringBuilder sb) private Datestatic StringFormat aDateinto RFC1123 formatprivate Stringprivate static DateFormatterprivate static intgetNumericalValue(char c) private static booleanisDelim(char c) private static booleanisDigit(char c) private booleanprivate Dateparse0(CharSequence txt, int start, int end) private booleanparse1(CharSequence txt, int start, int end) static DateParse some text into aDate, according to RFC6265static DateparseHttpDate(CharSequence txt, int start, int end) Parse some text into aDate, according to RFC6265private booleanparseToken(CharSequence txt, int tokenStart, int tokenEnd) voidreset()private booleantryParseDayOfMonth(CharSequence txt, int tokenStart, int tokenEnd) private booleantryParseMonth(CharSequence txt, int tokenStart, int tokenEnd) private booleantryParseTime(CharSequence txt, int tokenStart, int tokenEnd) private booleantryParseYear(CharSequence txt, int tokenStart, int tokenEnd)
-
Field Details
-
DELIMITERS
-
DAY_OF_WEEK_TO_SHORT_NAME
-
CALENDAR_MONTH_TO_SHORT_NAME
-
INSTANCES
-
cal
-
sb
-
timeFound
private boolean timeFound -
hours
private int hours -
minutes
private int minutes -
seconds
private int seconds -
dayOfMonthFound
private boolean dayOfMonthFound -
dayOfMonth
private int dayOfMonth -
monthFound
private boolean monthFound -
month
private int month -
yearFound
private boolean yearFound -
year
private int year
-
-
Constructor Details
-
DateFormatter
private DateFormatter()
-
-
Method Details
-
parseHttpDate
-
parseHttpDate
-
format
-
append
Append aDateto aStringBuilderinto RFC1123 format- Parameters:
date- the date to formatsb- the StringBuilder- Returns:
- the same StringBuilder
-
formatter
-
isDelim
private static boolean isDelim(char c) -
isDigit
private static boolean isDigit(char c) -
getNumericalValue
private static int getNumericalValue(char c) -
reset
public void reset() -
tryParseTime
-
tryParseDayOfMonth
-
tryParseMonth
-
tryParseYear
-
parseToken
-
parse0
-
parse1
-
normalizeAndValidate
private boolean normalizeAndValidate() -
computeDate
-
format0
-
append0
-
appendZeroLeftPadded
-