public class DateUtil
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
private static java.util.regex.Pattern |
DIGIT_PATTERN
Pattern to find digits only.
|
private static java.util.TimeZone |
GMT_ZONE |
private static java.util.Locale |
LOCALE |
private static java.text.DateFormat |
RFC_1123_FORMAT |
private static java.lang.String |
RFC_1123_PATTERN |
| Constructor and Description |
|---|
DateUtil() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
getCurrentAsString() |
static java.lang.String |
getDateAsString(java.util.Date date)
Convert a given
Date object to a RFC 1123
formatted String. |
private static long |
parseDateStringToMilliseconds(java.lang.String dateString)
Translate a given date
String in the RFC 1123
format to a long representing the number of milliseconds
since epoch. |
static long |
parseToMilliseconds(java.lang.String dateValue)
Parse a given date
String to a long
representation of the time. |
static java.lang.String |
parseToRFC1123(long dateValue)
Converts a millisecond representation of a date to a
RFC 1123 formatted String. |
private static final java.util.Locale LOCALE
private static final java.util.TimeZone GMT_ZONE
private static final java.lang.String RFC_1123_PATTERN
private static final java.text.DateFormat RFC_1123_FORMAT
private static final java.util.regex.Pattern DIGIT_PATTERN
public static java.lang.String getCurrentAsString()
private static long parseDateStringToMilliseconds(java.lang.String dateString)
String in the RFC 1123
format to a long representing the number of milliseconds
since epoch.dateString - a date String in the RFC 1123
format.Date in milliseconds.public static long parseToMilliseconds(java.lang.String dateValue)
String to a long
representation of the time. Where the provided value is all digits the
value is returned as a long, otherwise attempt is made to
parse the String as a RFC 1123 date.dateValue - the value to parse.long value following parse, or zero where not
successful.public static java.lang.String parseToRFC1123(long dateValue)
RFC 1123 formatted String.dateValue - the Date represented as milliseconds.String representation of the date.public static java.lang.String getDateAsString(java.util.Date date)
Date object to a RFC 1123
formatted String.date - the Date object to convertString representation of the date.