io.undertow.util

## Class DateUtils

- java.lang.Object
- - io.undertow.util.DateUtils

    public class DateUtils
    extends Object

Utility for parsing and generating dates

Author:
  Stuart Douglas

### Method Summary

All Methods Static Methods Concrete Methods
`static void` `addDateHeaderIfRequired(HttpServerExchange exchange)`
`static String` `getCurrentDateTime(HttpServerExchange exchange)`
`static boolean` `handleIfModifiedSince(HttpServerExchange exchange, Date lastModified)` Handles the if-modified-since header.
`static boolean` `handleIfModifiedSince(String modifiedSince, Date lastModified)` Handles the if-modified-since header.
`static boolean` `handleIfUnmodifiedSince(HttpServerExchange exchange, Date lastModified)` Handles the if-unmodified-since header.
`static boolean` `handleIfUnmodifiedSince(String modifiedSince, Date lastModified)` Handles the if-unmodified-since header.
`static Date` `parseDate(String date)` Attempts to pass a HTTP date.
`static String` `toCommonLogFormat(Date date)`
`static String` `toDateString(Date date)` Converts a date to a format suitable for use in a HTTP request
`static String` `toOldCookieDateString(Date date)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Method Detail

#### toDateString

    public static String toDateString(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 String toOldCookieDateString(Date date)

#### toCommonLogFormat

    public static String toCommonLogFormat(Date date)

#### parseDate

    public static Date parseDate(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,
                                                Date lastModified)

Handles the if-modified-since header. returns true if the request should proceed, false otherwise

Parameters:
  `exchange` - the exchange
  `lastModified` - The last modified date
Returns:

#### handleIfModifiedSince

    public static boolean handleIfModifiedSince(String modifiedSince,
                                                Date lastModified)

Handles the if-modified-since header. returns true if the request should proceed, false otherwise

Parameters:
  `modifiedSince` - the modified since date
  `lastModified` - The last modified date
Returns:

#### handleIfUnmodifiedSince

    public static boolean handleIfUnmodifiedSince(HttpServerExchange exchange,
                                                  Date lastModified)

Handles the if-unmodified-since header. returns true if the request should proceed, false otherwise

Parameters:
  `exchange` - the exchange
  `lastModified` - The last modified date
Returns:

#### handleIfUnmodifiedSince

    public static boolean handleIfUnmodifiedSince(String modifiedSince,
                                                  Date lastModified)

Handles the if-unmodified-since header. returns true if the request should proceed, false otherwise

Parameters:
  `modifiedSince` - the if unmodified since date
  `lastModified` - The last modified date
Returns:

#### addDateHeaderIfRequired

    public static void addDateHeaderIfRequired(HttpServerExchange exchange)

#### getCurrentDateTime

    public static String getCurrentDateTime(HttpServerExchange exchange)