public final class DateUtil
A utility class that centralizes processing of dates.
Static Fields
MILLISECONDS_IN_DAY
public static final int MILLISECONDS_IN_DAY
The milliseconds in a day.
Field Value | |
---|---|
Type | Description |
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 | |
---|---|
Name | Description |
date | String the date string to deserialize into a date |
Returns | |
---|---|
Type | Description |
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 | |
---|---|
Name | Description |
date | Date the date to format as a string |
Returns | |
---|---|
Type | Description |
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 | |
---|---|
Name | Description |
days | int the number of days to add to the UNIX Epoch to get a Date |
milliseconds | int the number of milliseconds to add to the date |
Returns | |
---|---|
Type | Description |
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 | |
---|---|
Name | Description |
date | Date the date to serialize as a string |
Returns | |
---|---|
Type | Description |
String | a string representing the date as milliseconds since the UNIX Epoch |