Package io.undertow.util
Class DateUtils
- java.lang.Object
-
- io.undertow.util.DateUtils
-
public class DateUtils extends java.lang.ObjectUtility for parsing and generating dates- Author:
- Stuart Douglas
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddDateHeaderIfRequired(HttpServerExchange exchange)static java.lang.StringgetCurrentDateTime(HttpServerExchange exchange)static booleanhandleIfModifiedSince(HttpServerExchange exchange, java.util.Date lastModified)Handles the if-modified-since header.static booleanhandleIfModifiedSince(java.lang.String modifiedSince, java.util.Date lastModified)Handles the if-modified-since header.static booleanhandleIfUnmodifiedSince(HttpServerExchange exchange, java.util.Date lastModified)Handles the if-unmodified-since header.static booleanhandleIfUnmodifiedSince(java.lang.String modifiedSince, java.util.Date lastModified)Handles the if-unmodified-since header.static java.util.DateparseDate(java.lang.String date)Attempts to pass a HTTP date.static java.lang.StringtoCommonLogFormat(java.util.Date date)static java.lang.StringtoDateString(java.util.Date date)Converts a date to a format suitable for use in a HTTP requeststatic java.lang.StringtoOldCookieDateString(java.util.Date date)
-
-
-
Method Detail
-
toDateString
public static java.lang.String toDateString(java.util.Date date)
Converts a date to a format suitable for use in a HTTP request- Parameters:
date- The date- Returns:
- The RFC-1123 formatted date
-
toOldCookieDateString
public static java.lang.String toOldCookieDateString(java.util.Date date)
-
toCommonLogFormat
public static java.lang.String toCommonLogFormat(java.util.Date date)
-
parseDate
public static java.util.Date parseDate(java.lang.String date)
Attempts to pass a HTTP date.- Parameters:
date- The date to parse- Returns:
- The parsed date, or null if parsing failed
-
handleIfModifiedSince
public static boolean handleIfModifiedSince(HttpServerExchange exchange, java.util.Date lastModified)
Handles the if-modified-since header. returns true if the request should proceed, false otherwise- Parameters:
exchange- the exchangelastModified- The last modified date- Returns:
-
handleIfModifiedSince
public static boolean handleIfModifiedSince(java.lang.String modifiedSince, java.util.Date lastModified)Handles the if-modified-since header. returns true if the request should proceed, false otherwise- Parameters:
modifiedSince- the modified since datelastModified- The last modified date- Returns:
-
handleIfUnmodifiedSince
public static boolean handleIfUnmodifiedSince(HttpServerExchange exchange, java.util.Date lastModified)
Handles the if-unmodified-since header. returns true if the request should proceed, false otherwise- Parameters:
exchange- the exchangelastModified- The last modified date- Returns:
-
handleIfUnmodifiedSince
public static boolean handleIfUnmodifiedSince(java.lang.String modifiedSince, java.util.Date lastModified)Handles the if-unmodified-since header. returns true if the request should proceed, false otherwise- Parameters:
modifiedSince- the if unmodified since datelastModified- The last modified date- Returns:
-
addDateHeaderIfRequired
public static void addDateHeaderIfRequired(HttpServerExchange exchange)
-
getCurrentDateTime
public static java.lang.String getCurrentDateTime(HttpServerExchange exchange)
-
-