Class DateUtil (2.0.0)

public final class DateUtil

A utility class that centralizes processing of dates.

Inheritance

java.lang.Object > DateUtil

Static Fields

MILLISECONDS_IN_DAY

public static final int MILLISECONDS_IN_DAY

The milliseconds in a day.

Field Value
TypeDescription
int

Static Methods

deserializeDate(String date)

public static Date deserializeDate(String date)

Converts a string containing the milliseconds since the UNIX Epoch into a Date.

Two formats of date string are supported: "yyyy-MM-dd" and a long. Eventually, the "yyyy-MM-dd" format support will be removed.

Parameter
NameDescription
dateString

the date string to deserialize into a date

Returns
TypeDescription
Date

a date

formatDateTime(Date date)

public static String formatDateTime(Date date)

Formats a date according ISO 8601 full date time format. Currently, this is used to print dates for error messages.

Parameter
NameDescription
dateDate

the date to format as a string

Returns
TypeDescription
String

a string representing the date in ISO 8601 format

getEpochPlusDays(int days, int milliseconds)

public static final Date getEpochPlusDays(int days, int milliseconds)

Constructs a Date set to the UNIX Epoch plus days plus milliseconds.

Parameters
NameDescription
daysint

the number of days to add to the UNIX Epoch to get a Date

millisecondsint

the number of milliseconds to add to the date

Returns
TypeDescription
Date

the Date with number of days plus Epoch

serializeDate(Date date)

public static String serializeDate(Date date)

Converts date into a string containing the milliseconds since the UNIX Epoch.

Parameter
NameDescription
dateDate

the date to serialize as a string

Returns
TypeDescription
String

a string representing the date as milliseconds since the UNIX Epoch