Package org.restlet.engine.util
Class DateUtils
java.lang.Object
org.restlet.engine.util.DateUtils
Date manipulation utilities.
- Author:
- Jerome Louvel
-
Field Summary
FieldsModifier and TypeFieldDescriptionObsoleted HTTP date format (ANSI C asctime() format).AWS date format (ISO 8601).Obsoleted HTTP date format (RFC 1036).Preferred HTTP date format (RFC 1123).W3C date format (RFC 3339).Common date format (RFC 822). -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanCompares two date with a precision of one second.static booleanCompares two date with a precision of one second.static booleanCompares two date with a precision of one second.static StringFormats a Date in the default HTTP format (RFC 1123).static StringFormats a Date according to the given format.static StringFormats a Date according to the first format in the array.static DateParses a formatted date into a Date object using the default HTTP format (RFC 1123).static DateParses a formatted date into a Date object.static Dateunmodifiable(Date date) Returns an immutable version of a given date.
-
Field Details
-
FORMAT_ASC_TIME
Obsoleted HTTP date format (ANSI C asctime() format). Pattern: "EEE MMM dd HH:mm:ss yyyy". -
FORMAT_RFC_1036
Obsoleted HTTP date format (RFC 1036). Pattern: "EEEE, dd-MMM-yy HH:mm:ss zzz". -
FORMAT_RFC_1123
Preferred HTTP date format (RFC 1123). Pattern: "EEE, dd MMM yyyy HH:mm:ss zzz". -
FORMAT_RFC_3339
W3C date format (RFC 3339). Pattern: "yyyy-MM-dd'T'HH:mm:ssz". -
FORMAT_ISO_8601
AWS date format (ISO 8601). Pattern: "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'". -
FORMAT_RFC_822
Common date format (RFC 822). Patterns: "EEE, dd MMM yy HH:mm:ss z" or "EEE, dd MMM yy HH:mm z", "dd MMM yy HH:mm:ss z" or "dd MMM yy HH:mm z".
-
-
Method Details
-
after
Compares two date with a precision of one second.- Parameters:
baseDate- The base dateafterDate- The date supposed to be after.- Returns:
- True if the afterDate is indeed after the baseDate.
-
before
Compares two date with a precision of one second.- Parameters:
baseDate- The base datebeforeDate- The date supposed to be before.- Returns:
- True if the beforeDate is indeed before the baseDate.
-
equals
Compares two date with a precision of one second.- Parameters:
baseDate- The base dateotherDate- The other date supposed to be equals.- Returns:
- True if both dates are equals.
-
format
Formats a Date in the default HTTP format (RFC 1123).- Parameters:
date- The date to format.- Returns:
- The formatted date.
-
format
Formats a Date according to the first format in the array.- Parameters:
date- The date to format.formats- The array of date formats to use.- Returns:
- The formatted date.
-
format
Formats a Date according to the given format.- Parameters:
date- The date to format.format- The date format to use.- Returns:
- The formatted date.
-
parse
Parses a formatted date into a Date object using the default HTTP format (RFC 1123).- Parameters:
date- The date to parse.- Returns:
- The parsed date.
-
parse
Parses a formatted date into a Date object.- Parameters:
date- The date to parse.formats- The date formats to use sorted by completeness.- Returns:
- The parsed date.
-
unmodifiable
Returns an immutable version of a given date.- Parameters:
date- The modifiable date.- Returns:
- An immutable version of a given date.
-