| Modifier and Type | Method and Description |
|---|---|
static Date |
copy(Date date)
Returns a copy of the given
Date. |
static String |
format(Date date,
String format)
Returns the
String representation of the given Date
according to the specified format pattern. |
static boolean |
isSameDay(Calendar cal1,
Calendar cal2)
Returns whether the given
Calendars represent the same day. |
static boolean |
isSameDay(Date date1,
Date date2)
Returns whether the given
Dates represent the same day. |
static boolean |
isSameInstant(Calendar cal1,
Calendar cal2)
Returns whether the given
Calendars represent the same instant. |
static boolean |
isSameInstant(Date date1,
Date date2)
Returns whether the given
Dates represent the same instant. |
static boolean |
isSameLocalTime(Calendar cal1,
Calendar cal2)
Returns whether the given
Calendars represent the same local time. |
static boolean |
isSameLocalTime(Date date1,
Date date2)
Returns whether the given
Dates represent the same local time. |
static boolean |
isSameMonth(Calendar cal1,
Calendar cal2)
Returns whether the given
Calendars represent the same month. |
static boolean |
isSameMonth(Date date1,
Date date2)
Returns whether the given
Dates represent the same month. |
static boolean |
isSameWeek(Calendar cal1,
Calendar cal2)
Returns whether the given
Calendars represent the same week. |
static boolean |
isSameWeek(Date date1,
Date date2)
Returns whether the given
Dates represent the same week. |
static boolean |
isSameYear(Calendar cal1,
Calendar cal2)
Returns whether the given
Calendars represent the same year. |
static boolean |
isSameYear(Date date1,
Date date2)
Returns whether the given
Dates represent the same year. |
static Date |
now()
Returns a new
Date representing the current instant. |
static Date |
parse(String date,
Locale locale,
String... formats)
Parses a
String representing a date into a Date
instance. |
static Date |
parse(String date,
String... formats)
Parses a
String representing a date into a Date
instance. |
static Calendar |
toCalendar(Date date)
Converts a
Date into a Calendar. |
public static Date copy(Date date)
Date.date - the Date to copy.Date or null if it was
null.public static Date now()
Date representing the current instant.Date representing the current instant.public static boolean isSameInstant(Date date1, Date date2)
Dates represent the same instant.date1 - the first Date.date2 - the second Date.Dates represent the same instant.NullPointerException - if one of the arguments is null.public static boolean isSameInstant(Calendar cal1, Calendar cal2)
Calendars represent the same instant.cal1 - the first Calendar.cal2 - the second Calendar.Calendars represent the same instant.NullPointerException - if one of the arguments is null.public static boolean isSameLocalTime(Date date1, Date date2)
Dates represent the same local time.date1 - the first Date.date2 - the second Date.Dates represent the same local time.NullPointerException - if one of the arguments is null.public static boolean isSameLocalTime(Calendar cal1, Calendar cal2)
Calendars represent the same local time.cal1 - the first Calendar.cal2 - the second Calendar.Calendars represent the same local time.NullPointerException - if one of the arguments is null.public static boolean isSameDay(Date date1, Date date2)
Dates represent the same day.date1 - the first Date.date2 - the second Date.Dates represent the same day.NullPointerException - if one of the arguments is null.public static boolean isSameDay(Calendar cal1, Calendar cal2)
Calendars represent the same day.cal1 - the first Calendar.cal2 - the second Calendar.Calendars represent the same day.NullPointerException - if one of the arguments is null.public static boolean isSameWeek(Date date1, Date date2)
Dates represent the same week.date1 - the first Date.date2 - the second Date.Dates represent the same week.NullPointerException - if one of the arguments is null.public static boolean isSameWeek(Calendar cal1, Calendar cal2)
Calendars represent the same week.cal1 - the first Calendar.cal2 - the second Calendar.Calendars represent the same week.NullPointerException - if one of the arguments is null.public static boolean isSameMonth(Date date1, Date date2)
Dates represent the same month.date1 - the first Date.date2 - the second Date.Dates represent the same month.NullPointerException - if one of the arguments is null.public static boolean isSameMonth(Calendar cal1, Calendar cal2)
Calendars represent the same month.cal1 - the first Calendar.cal2 - the second Calendar.Calendars represent the same month.NullPointerException - if one of the arguments is null.public static boolean isSameYear(Date date1, Date date2)
Dates represent the same year.date1 - the first Date.date2 - the second Date.Dates represent the same year.NullPointerException - if one of the arguments is null.public static boolean isSameYear(Calendar cal1, Calendar cal2)
Calendars represent the same year.cal1 - the first Calendar.cal2 - the second Calendar.Calendars represent the same year.NullPointerException - if one of the arguments is null.public static Date parse(String date, String... formats)
String representing a date into a Date
instance. The given formats will be used sequentially until a
successful parsing is obtained. A parsing is considered successful
if it parses the whole input String.date - the String to parse.formats - the date format patterns to use.Date.NullPointerException - if one of the arguments is null
or if formats contains a null reference.IllegalArgumentException - if formats is empty or if
date can't be parsed with any of the specified formats.public static Date parse(String date, Locale locale, String... formats)
String representing a date into a Date
instance. The given formats will be used sequentially until a
successful parsing is obtained. A parsing is considered successful
if it parses the whole input String.date - the String to parse.locale - the Locale to use.formats - the date format patterns to use.Date.NullPointerException - if one of the arguments is null
or if formats contains a null reference.IllegalArgumentException - if formats is empty or if
date can't be parsed with any of the specified formats.public static String format(Date date, String format)
String representation of the given Date
according to the specified format pattern.date - the Date to format.format - the format pattern to use.String representation of date.NullPointerException - if one of the arguments is null.public static Calendar toCalendar(Date date)
Date into a Calendar.date - the Date to convert to a Calendar.Calendar instance.NullPointerException - if date is null.Copyright © 2012–2015. All rights reserved.