| Modifier and Type | Field and Description |
|---|---|
| private static final DateFormat | ISO_DATE_FORMAT
ISO 8601 date format (yyyy-MM-dd), example : |
| private static final DateFormat | ISO_DATE_TIME_FORMAT
ISO 8601 local date-time format (yyyy-MM-dd'T'HH:mm:ss), example : |
| private static final DateFormat | ISO_DATE_TIME_FORMAT_WITH_MS
ISO 8601 local date-time format with millisecond (yyyy-MM-dd'T'HH:mm:ss.SSS), example :
|
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| private static DateFormat | |
| public static int | Returns: the day of month of the given Datethe date to extract the day of month from - must not be null. date)Dates Extracts the day of month of the given Date. |
| public static int | Returns: the day of week of the given Datethe date to extract the day of week from - must not be null. date)Extracts the day of week of the given Date, returned value follows |
| public static synchronized String | Returns: the formatted date or null if given the date was null.the date to format. date)Formats the given date using the ISO 8601 date-time format (yyyy-MM-dd'T'HH:mm:ss). |
| public static String | Returns: the formatted calendar or null if the given calendar was null.the calendar to format. calendar)Formats the date of the given calendar using the ISO 8601 date-time format (yyyy-MM-dd'T'HH:mm:ss). |
| public static synchronized String | Returns: the formatted date or null if given the date was null.the date to format. date)Formats the given date using the ISO 8601 date-time format with millisecond (yyyy-MM-dd'T'HH:mm:ss:SSS). |
| public static String | Returns: a human readable time difference.the first date date1, final Date the second date date2)Utility method to display a human readable time difference. |
| public static int | Returns: the hour of day of the given Date (24-hour clock)the date to extract the hour of day from - must not be null. date)Extracts the hour of day if the given Date (24-hour clock). |
| public static int | Returns: the millisecond of the given Datethe date to extract the millisecond from - must not be null. date)Extracts the millisecond of the given Date. |
| public static int | |
| public static int | |
| public static DateFormat | |
| public static DateFormat | newIsoDateFormat(boolean
whether or not parsing the date is lenient lenientParsing)ISO 8601 date format (yyyy-MM-dd), example : |
| public static DateFormat | newIsoDateTimeFormat()
ISO 8601 date-time format (yyyy-MM-dd'T'HH:mm:ss), example : |
| public static DateFormat | newIsoDateTimeFormat(boolean
whether or not parsing the date is lenient lenientParsing)ISO 8601 date-time format (yyyy-MM-dd'T'HH:mm:ss), example : |
| public static DateFormat | newIsoDateTimeWithIsoTimeZoneFormat()
ISO 8601 date-time format with ISO time zone (yyyy-MM-dd'T'HH:mm:ssX), example :
|
| public static DateFormat | newIsoDateTimeWithIsoTimeZoneFormat(boolean
whether or not parsing the date is lenient lenientParsing)ISO 8601 date-time format with ISO time zone (yyyy-MM-dd'T'HH:mm:ssX), example :
|
| public static DateFormat | newIsoDateTimeWithMsAndIsoTimeZoneFormat()
ISO 8601 date-time format with millisecond and ISO time zone (yyyy-MM-dd'T'HH:mm:ss.SSSX), example :
|
| public static DateFormat | newIsoDateTimeWithMsAndIsoTimeZoneFormat(boolean
whether or not parsing the date is lenient lenientParsing)ISO 8601 date-time format with millisecond and ISO time zone (yyyy-MM-dd'T'HH:mm:ss.SSSX), example :
|
| public static DateFormat | newIsoDateTimeWithMsFormat()
ISO 8601 date-time format with millisecond (yyyy-MM-dd'T'HH:mm:ss.SSS), example :
|
| public static DateFormat | newIsoDateTimeWithMsFormat(boolean
whether or not parsing the date is lenient lenientParsing)ISO 8601 date-time format with millisecond (yyyy-MM-dd'T'HH:mm:ss.SSS), example :
|
| public static DateFormat | newTimestampDateFormat()
|
| public static DateFormat | newTimestampDateFormat(boolean
whether or not parsing the date is lenient lenientParsing)
|
| public static Date | |
| public static synchronized Date | Returns: the corresponding Date or null if the given String is null.the string to parse as a Date following dateAsString)ISO_DATE_FORMATUtility method to parse a Date following |
| public static synchronized Date | Returns: the corresponding Date with time details or null if the given String is null.the string to parse as a Date following dateAsString)ISO_DATE_TIME_FORMATUtility method to parse a Date following |
| public static synchronized Date | Returns: the corresponding Date with time details or null if the given String is null.the string to parse as a Date following dateAsString)ISO_DATE_TIME_FORMAT_WITH_MSUtility method to parse a Date following |
| public static int | |
| public static long | Returns: the difference between the two given dates in millisecondsthe first date. date1, Date the second date. date2)Compute the time difference between the two given dates in milliseconds, it always gives a positive result. |
| public static Calendar | Returns: the Calendar corresponding to the given Date or null if the given Date is null.the date to convert to a Calendar. date)Converts the given Date to Calendar, returns null if the given Date is null. |
| public static Date | |
| public static Date | Returns: the truncated date.we want to get the day part (the parameter is read only). date)Returns a copy of the given date without the time part (which is set to 00:00:00), for example :
|
| public static int | |
| public static Date |
| ISO_DATE_FORMAT | back to summary |
|---|---|
| private static final DateFormat ISO_DATE_FORMAT ISO 8601 date format (yyyy-MM-dd), example : | |
| ISO_DATE_TIME_FORMAT | back to summary |
|---|---|
| private static final DateFormat ISO_DATE_TIME_FORMAT ISO 8601 local date-time format (yyyy-MM-dd'T'HH:mm:ss), example : | |
| ISO_DATE_TIME_FORMAT_WITH_MS | back to summary |
|---|---|
| private static final DateFormat ISO_DATE_TIME_FORMAT_WITH_MS ISO 8601 local date-time format with millisecond (yyyy-MM-dd'T'HH:mm:ss.SSS), example :
| |
| DateUtil | back to summary |
|---|---|
| public DateUtil() | |
| dateFormatForPattern | back to summary |
|---|---|
| private static DateFormat dateFormatForPattern(String pattern, boolean lenient) | |
| dayOfMonthOf | back to summary |
|---|---|
| public static int dayOfMonthOf(Date date) Dates Extracts the day of month of the given Date.
| |
| dayOfWeekOf | back to summary |
|---|---|
| public static int dayOfWeekOf(Date date) Extracts the day of week of the given Date, returned value follows
| |
| formatAsDatetime | back to summary |
|---|---|
| public static synchronized String formatAsDatetime(Date date) Formats the given date using the ISO 8601 date-time format (yyyy-MM-dd'T'HH:mm:ss). Returns null if given the date is null. | |
| formatAsDatetime | back to summary |
|---|---|
| public static String formatAsDatetime(Calendar calendar) Formats the date of the given calendar using the ISO 8601 date-time format (yyyy-MM-dd'T'HH:mm:ss). Returns null if the given calendar is null. | |
| formatAsDatetimeWithMs | back to summary |
|---|---|
| public static synchronized String formatAsDatetimeWithMs(Date date) Formats the given date using the ISO 8601 date-time format with millisecond (yyyy-MM-dd'T'HH:mm:ss:SSS). Returns null if given the date is null. | |
| formatTimeDifference | back to summary |
|---|---|
| public static String formatTimeDifference(final Date date1, final Date date2) Utility method to display a human readable time difference. | |
| hourOfDayOf | back to summary |
|---|---|
| public static int hourOfDayOf(Date date) Extracts the hour of day if the given Date (24-hour clock).
| |
| millisecondOf | back to summary |
|---|---|
| public static int millisecondOf(Date date) Extracts the millisecond of the given Date.
| |
| minuteOf | back to summary |
|---|---|
| public static int minuteOf(Date date) Dates Extracts the minute of the given Date.
| |
| monthOf | back to summary |
|---|---|
| public static int monthOf(Date date) Dates Extracts the month of the given Date starting at 1 (January=1, February=2, ...).
| |
| newIsoDateFormat | back to summary |
|---|---|
| public static DateFormat newIsoDateFormat() ISO 8601 date format (yyyy-MM-dd), example :
| |
| newIsoDateFormat | back to summary |
|---|---|
| public static DateFormat newIsoDateFormat(boolean lenientParsing) ISO 8601 date format (yyyy-MM-dd), example :
| |
| newIsoDateTimeFormat | back to summary |
|---|---|
| public static DateFormat newIsoDateTimeFormat() ISO 8601 date-time format (yyyy-MM-dd'T'HH:mm:ss), example :
| |
| newIsoDateTimeFormat | back to summary |
|---|---|
| public static DateFormat newIsoDateTimeFormat(boolean lenientParsing) ISO 8601 date-time format (yyyy-MM-dd'T'HH:mm:ss), example :
| |
| newIsoDateTimeWithIsoTimeZoneFormat | back to summary |
|---|---|
| public static DateFormat newIsoDateTimeWithIsoTimeZoneFormat() ISO 8601 date-time format with ISO time zone (yyyy-MM-dd'T'HH:mm:ssX), example :
| |
| newIsoDateTimeWithIsoTimeZoneFormat | back to summary |
|---|---|
| public static DateFormat newIsoDateTimeWithIsoTimeZoneFormat(boolean lenientParsing) ISO 8601 date-time format with ISO time zone (yyyy-MM-dd'T'HH:mm:ssX), example :
| |
| newIsoDateTimeWithMsAndIsoTimeZoneFormat | back to summary |
|---|---|
| public static DateFormat newIsoDateTimeWithMsAndIsoTimeZoneFormat() ISO 8601 date-time format with millisecond and ISO time zone (yyyy-MM-dd'T'HH:mm:ss.SSSX), example :
| |
| newIsoDateTimeWithMsAndIsoTimeZoneFormat | back to summary |
|---|---|
| public static DateFormat newIsoDateTimeWithMsAndIsoTimeZoneFormat(boolean lenientParsing) ISO 8601 date-time format with millisecond and ISO time zone (yyyy-MM-dd'T'HH:mm:ss.SSSX), example :
| |
| newIsoDateTimeWithMsFormat | back to summary |
|---|---|
| public static DateFormat newIsoDateTimeWithMsFormat() ISO 8601 date-time format with millisecond (yyyy-MM-dd'T'HH:mm:ss.SSS), example :
| |
| newIsoDateTimeWithMsFormat | back to summary |
|---|---|
| public static DateFormat newIsoDateTimeWithMsFormat(boolean lenientParsing) ISO 8601 date-time format with millisecond (yyyy-MM-dd'T'HH:mm:ss.SSS), example :
| |
| newTimestampDateFormat | back to summary |
|---|---|
| public static DateFormat newTimestampDateFormat()
| |
| newTimestampDateFormat | back to summary |
|---|---|
| public static DateFormat newTimestampDateFormat(boolean lenientParsing)
| |
| now | back to summary |
|---|---|
| public static Date now() | |
| parse | back to summary |
|---|---|
| public static synchronized Date parse(String dateAsString) Utility method to parse a Date following
| |
| parseDatetime | back to summary |
|---|---|
| public static synchronized Date parseDatetime(String dateAsString) Utility method to parse a Date following Example:
| |
| parseDatetimeWithMs | back to summary |
|---|---|
| public static synchronized Date parseDatetimeWithMs(String dateAsString) Utility method to parse a Date following Example:
| |
| secondOf | back to summary |
|---|---|
| public static int secondOf(Date date) Extracts the second of the given Date.
| |
| timeDifference | back to summary |
|---|---|
| public static long timeDifference(Date date1, Date date2) Compute the time difference between the two given dates in milliseconds, it always gives a positive result.
| |
| toCalendar | back to summary |
|---|---|
| public static Calendar toCalendar(Date date) Converts the given Date to Calendar, returns null if the given Date is null. | |
| tomorrow | back to summary |
|---|---|
| public static Date tomorrow() | |
| truncateTime | back to summary |
|---|---|
| public static Date truncateTime(Date date) Returns a copy of the given date without the time part (which is set to 00:00:00), for example : Returns null if the given Date is null. | |
| yearOf | back to summary |
|---|---|
| public static int yearOf(Date date) Extracts the year of the given Date.
| |
| yesterday | back to summary |
|---|---|
| public static Date yesterday() | |