Package org.apache.mina.http
Class DateUtil
- java.lang.Object
-
- org.apache.mina.http.DateUtil
-
public class DateUtil extends java.lang.ObjectAn utility class for Dates manipulations
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.regex.PatternDIGIT_PATTERNPattern to find digits only.private static java.util.TimeZoneGMT_ZONEprivate static java.util.LocaleLOCALEprivate static java.text.DateFormatRFC_1123_FORMATprivate static java.lang.StringRFC_1123_PATTERN
-
Constructor Summary
Constructors Modifier Constructor Description privateDateUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringgetCurrentAsString()static java.lang.StringgetDateAsString(java.util.Date date)Convert a givenDateobject to aRFC 1123formattedString.private static longparseDateStringToMilliseconds(java.lang.String dateString)Translate a given dateStringin the RFC 1123 format to alongrepresenting the number of milliseconds since epoch.static longparseToMilliseconds(java.lang.String dateValue)Parse a given dateStringto alongrepresentation of the time.static java.lang.StringparseToRFC1123(long dateValue)Converts a millisecond representation of a date to aRFC 1123formattedString.
-
-
-
Field Detail
-
LOCALE
private static final java.util.Locale LOCALE
-
GMT_ZONE
private static final java.util.TimeZone GMT_ZONE
-
RFC_1123_PATTERN
private static final java.lang.String RFC_1123_PATTERN
- See Also:
- Constant Field Values
-
RFC_1123_FORMAT
private static final java.text.DateFormat RFC_1123_FORMAT
-
DIGIT_PATTERN
private static final java.util.regex.Pattern DIGIT_PATTERN
Pattern to find digits only.
-
-
Method Detail
-
getCurrentAsString
public static java.lang.String getCurrentAsString()
- Returns:
- The current date as a string
-
parseDateStringToMilliseconds
private static long parseDateStringToMilliseconds(java.lang.String dateString)
Translate a given dateStringin the RFC 1123 format to alongrepresenting the number of milliseconds since epoch.- Parameters:
dateString- a dateStringin the RFC 1123 format.- Returns:
- the parsed
Datein milliseconds.
-
parseToMilliseconds
public static long parseToMilliseconds(java.lang.String dateValue)
Parse a given dateStringto alongrepresentation of the time. Where the provided value is all digits the value is returned as along, otherwise attempt is made to parse theStringas a RFC 1123 date.- Parameters:
dateValue- the value to parse.- Returns:
- the
longvalue following parse, or zero where not successful.
-
parseToRFC1123
public static java.lang.String parseToRFC1123(long dateValue)
Converts a millisecond representation of a date to aRFC 1123formattedString.- Parameters:
dateValue- theDaterepresented as milliseconds.- Returns:
- a
Stringrepresentation of the date.
-
getDateAsString
public static java.lang.String getDateAsString(java.util.Date date)
Convert a givenDateobject to aRFC 1123formattedString.- Parameters:
date- theDateobject to convert- Returns:
- a
Stringrepresentation of the date.
-
-