Package ca.uhn.fhir.util
Class DateUtils
- java.lang.Object
-
- ca.uhn.fhir.util.DateUtils
-
public final class DateUtils extends Object
A utility class for parsing and formatting HTTP dates as used in cookies and other headers. This class handles dates as defined by RFC 2616 section 3.3.1 as well as some other common non-standard formats.This class is basically intended to be a high-performance workaround for the fact that Java SimpleDateFormat is kind of expensive to create and yet isn't thread safe.
This class was adapted from the class with the same name from the Jetty project, licensed under the terms of the Apache Software License 2.0.
-
-
Field Summary
Fields Modifier and Type Field Description static TimeZoneGMTGMT TimeZonestatic StringPATTERN_ASCTIMEDate format pattern used to parse HTTP date headers in ANSI Casctime()format.static StringPATTERN_RFC1036Date format pattern used to parse HTTP date headers in RFC 1036 format.static StringPATTERN_RFC1123Date format pattern used to parse HTTP date headers in RFC 1123 format.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intconvertDatetoDayInteger(Date theDateValue)static StringconvertDateToIso8601String(Date theDateValue)static StringformatDate(Date date)Formats the given date according to the RFC 1123 pattern.static DategetHighestInstantFromDate(Date theDateValue)static DategetInstantFromDateWithTimezone(Date theDateValue, TimeZone theTimezone)static DategetLowestInstantFromDate(Date theDateValue)static <T> TnotNull(T argument, String name)static DateparseDate(String theDateValue)Parses a date value.
-
-
-
Field Detail
-
PATTERN_RFC1123
public static final String PATTERN_RFC1123
Date format pattern used to parse HTTP date headers in RFC 1123 format.- See Also:
- Constant Field Values
-
PATTERN_RFC1036
public static final String PATTERN_RFC1036
Date format pattern used to parse HTTP date headers in RFC 1036 format.- See Also:
- Constant Field Values
-
PATTERN_ASCTIME
public static final String PATTERN_ASCTIME
Date format pattern used to parse HTTP date headers in ANSI Casctime()format.- See Also:
- Constant Field Values
-
-
Method Detail
-
parseDate
public static Date parseDate(String theDateValue)
Parses a date value. The formats used for parsing the date value are retrieved from the default http params.- Parameters:
theDateValue- the date value to parse- Returns:
- the parsed date or null if input could not be parsed
-
getHighestInstantFromDate
public static Date getHighestInstantFromDate(Date theDateValue)
-
getLowestInstantFromDate
public static Date getLowestInstantFromDate(Date theDateValue)
-
getInstantFromDateWithTimezone
public static Date getInstantFromDateWithTimezone(Date theDateValue, TimeZone theTimezone)
-
convertDatetoDayInteger
public static int convertDatetoDayInteger(Date theDateValue)
-
convertDateToIso8601String
public static String convertDateToIso8601String(Date theDateValue)
-
formatDate
public static String formatDate(Date date)
Formats the given date according to the RFC 1123 pattern.- Parameters:
date- The date to format.- Returns:
- An RFC 1123 formatted date string.
- See Also:
PATTERN_RFC1123
-
-