public final class DateUtils extends Object
Modifier and Type | Field and Description |
---|---|
static DateTimeFormatter |
FORMATTER_ASCTIME
Date formatter used to parse HTTP date headers in in ANSI C
asctime() format. |
static DateTimeFormatter |
FORMATTER_RFC1036
Date formatter used to parse HTTP date headers in RFC 1036 format.
|
static DateTimeFormatter |
FORMATTER_RFC1123
Date formatter used to parse HTTP date headers in the Internet Message Format
specified by the HTTP protocol.
|
static TimeZone |
GMT
Deprecated.
This attribute is no longer supported as a part of the public API.
|
static String |
INTERNET_MESSAGE_FORMAT |
static String |
PATTERN_ASCTIME
Date format pattern used to parse HTTP date headers in ANSI C
asctime() format. |
static String |
PATTERN_RFC1036
Date format pattern used to parse HTTP date headers in RFC 1036 format.
|
static String |
PATTERN_RFC1123
Deprecated.
|
static DateTimeFormatter[] |
STANDARD_PATTERNS
|
Modifier and Type | Method and Description |
---|---|
static void |
clearThreadLocal()
Deprecated.
Noop method. Do not use.
|
static String |
formatDate(Date date)
Deprecated.
|
static String |
formatDate(Date date,
String pattern)
Deprecated.
|
static String |
formatDate(Instant instant,
DateTimeFormatter dateTimeFormatter)
Formats the given date according to the specified pattern.
|
static String |
formatStandardDate(Instant instant)
Formats the given instant according to the RFC 1123 pattern.
|
static boolean |
isAfter(org.apache.hc.core5.http.MessageHeaders message1,
org.apache.hc.core5.http.MessageHeaders message2,
String headerName)
Deprecated.
This method is no longer supported as a part of the public API.
|
static boolean |
isBefore(org.apache.hc.core5.http.MessageHeaders message1,
org.apache.hc.core5.http.MessageHeaders message2,
String headerName)
Deprecated.
This method is no longer supported as a part of the public API.
|
static Date |
parseDate(org.apache.hc.core5.http.MessageHeaders headers,
String headerName)
Deprecated.
|
static Date |
parseDate(String dateValue)
Deprecated.
|
static Instant |
parseDate(String dateValue,
DateTimeFormatter... dateFormatters)
Parses the date value using the given date/time formats.
|
static Date |
parseDate(String dateValue,
String[] dateFormats)
Deprecated.
|
static Date |
parseDate(String dateValue,
String[] dateFormats,
Date startDate)
Deprecated.
|
static Instant |
parseStandardDate(org.apache.hc.core5.http.MessageHeaders headers,
String headerName)
Parses an instant value from a header with the given name.
|
static Instant |
parseStandardDate(String dateValue)
Parses the instant value using the standard date/time formats (
PATTERN_RFC1123 ,
PATTERN_RFC1036 , PATTERN_ASCTIME ). |
static Date |
toDate(Instant instant) |
static Instant |
toInstant(Date date) |
static LocalDateTime |
toUTC(Date date) |
static LocalDateTime |
toUTC(Instant instant) |
@Deprecated public static final String PATTERN_RFC1123
INTERNET_MESSAGE_FORMAT
public static final String INTERNET_MESSAGE_FORMAT
public static final DateTimeFormatter FORMATTER_RFC1123
public static final String PATTERN_RFC1036
public static final DateTimeFormatter FORMATTER_RFC1036
public static final String PATTERN_ASCTIME
asctime()
format.public static final DateTimeFormatter FORMATTER_ASCTIME
asctime()
format.public static final DateTimeFormatter[] STANDARD_PATTERNS
@Deprecated public static final TimeZone GMT
public static LocalDateTime toUTC(Instant instant)
public static LocalDateTime toUTC(Date date)
public static Instant parseDate(String dateValue, DateTimeFormatter... dateFormatters)
This method can handle strings without time-zone information by failing gracefully, in which case
it returns null
.
dateValue
- the instant value to parsedateFormatters
- the date/time formats to usepublic static Instant parseStandardDate(String dateValue)
PATTERN_RFC1123
,
PATTERN_RFC1036
, PATTERN_ASCTIME
).dateValue
- the instant value to parsepublic static Instant parseStandardDate(org.apache.hc.core5.http.MessageHeaders headers, String headerName)
headers
- message headersheaderName
- header namepublic static String formatStandardDate(Instant instant)
instant
- Instant to format.PATTERN_RFC1123
public static String formatDate(Instant instant, DateTimeFormatter dateTimeFormatter)
instant
- Instant to format.dateTimeFormatter
- The pattern to use for formatting the instant.IllegalArgumentException
- If the given date pattern is invalid.@Deprecated public static Date parseDate(String dateValue)
parseStandardDate(String)
dateValue
- the date value to parse@Deprecated public static Date parseDate(org.apache.hc.core5.http.MessageHeaders headers, String headerName)
parseStandardDate(MessageHeaders, String)
headers
- message headersheaderName
- header name@Deprecated public static boolean isAfter(org.apache.hc.core5.http.MessageHeaders message1, org.apache.hc.core5.http.MessageHeaders message2, String headerName)
message1
- the first messagemessage2
- the second messageheaderName
- header nametrue
if both messages contain a header with the given name
and the value of the header from the first message is newer that of
the second message.@Deprecated public static boolean isBefore(org.apache.hc.core5.http.MessageHeaders message1, org.apache.hc.core5.http.MessageHeaders message2, String headerName)
message1
- the first messagemessage2
- the second messageheaderName
- header nametrue
if both messages contain a header with the given name
and the value of the header from the first message is older that of
the second message.@Deprecated public static Date parseDate(String dateValue, String[] dateFormats)
parseDate(String, DateTimeFormatter...)
dateValue
- the date value to parsedateFormats
- the date/time formats to use@Deprecated public static Date parseDate(String dateValue, String[] dateFormats, Date startDate)
parseDate(String, DateTimeFormatter...)
dateValue
- the date value to parsedateFormats
- the date/time formats to usestartDate
- During parsing, two digit years will be placed in the range
startDate
to startDate + 100 years
. This value may
be null
. When null
is given as a parameter, year
2000
will be used.@Deprecated public static String formatDate(Date date)
formatStandardDate(Instant)
date
- The date to format.PATTERN_RFC1123
@Deprecated public static String formatDate(Date date, String pattern)
formatDate(Instant, DateTimeFormatter)
date
- The date to format.pattern
- The pattern to use for formatting the date.IllegalArgumentException
- If the given date pattern is invalid.@Deprecated public static void clearThreadLocal()
DateFormat
cache.Copyright © 1999–2021 The Apache Software Foundation. All rights reserved.