public final class DateTimeUtil extends Object
| Modifier and Type | Method and Description |
|---|---|
static Calendar |
addDaysToCalendar(Calendar calendar,
int days)
Adds the specified amount of days to the given calendar field.
|
static Date |
addDaysToDate(Date date,
int days)
Adds the specified amount of days to the given date.
|
static Date |
addMillisToDate(Date date,
long millis)
Adds provided number of milliseconds to the Date.
|
static Date |
addYearsToDate(Date date,
int years)
Adds the specified amount of years to the given date.
|
static String |
dateToString(Calendar date)
Converts
Calendar date to string of "yyyy.MM.dd HH:mm:ss z" format. |
static String |
format(Date date,
String pattern)
Format passing date with specified pattern.
|
static String |
formatWithDefaultPattern(Date date)
Format passing date with default yyyy-MM-dd pattern.
|
static Calendar |
getCalendar(Date date)
Gets the date as
Calendar. |
static Calendar |
getCurrentTimeCalendar()
Gets a default
GregorianCalendar. |
static Date |
getCurrentTimeDate()
Gets current time consistently.
|
static long |
getCurrentTimeZoneOffset(Date date)
Gets the offset of time zone from UTC at the specified date.
|
static long |
getRelativeTime(Date date)
Gets the number of milliseconds since January 1, 1970, 00:00:00 GMT
represented by specified date.
|
static double |
getUtcMillisFromEpoch(Calendar calendar)
Gets the
Calendar as UTC milliseconds from the epoch. |
static boolean |
isInPast(Date date)
Defines if date is in past.
|
static Date |
parse(String date,
String format)
Parses passing date with specified format.
|
static Date |
parseWithDefaultPattern(String date)
Parses passing date with default yyyy-MM-dd pattern.
|
public static double getUtcMillisFromEpoch(Calendar calendar)
Calendar as UTC milliseconds from the epoch.calendar - the calendar to be converted to millispublic static Calendar getCurrentTimeCalendar()
GregorianCalendar.GregorianCalendar using the current time in the default
time zone with the default localepublic static Date getCurrentTimeDate()
public static Calendar addDaysToCalendar(Calendar calendar, int days)
calendar - the calendar field where to adddays - the amount of days to be addedpublic static boolean isInPast(Date date)
date - the date to be compared with current datetrue if given date is in past, false insteadpublic static long getRelativeTime(Date date)
date - the specified date to get timepublic static Date addMillisToDate(Date date, long millis)
public static Date addDaysToDate(Date date, int days)
date - the specified date to adddays - the amount of days to be addedDate object representing the calendar's time value (millisecond
offset from the Epoch)public static Date addYearsToDate(Date date, int years)
date - the specified date to addyears - the amount of years to be addedDate object representing the calendar's time value (millisecond
offset from the Epoch)public static Date parseWithDefaultPattern(String date)
date - is date to be parsepublic static Date parse(String date, String format)
date - the date to be parsedformat - the format of parsing the datepublic static String formatWithDefaultPattern(Date date)
date - the date to be formattedpublic static String format(Date date, String pattern)
date - date to be formattedpattern - pattern for formatpublic static long getCurrentTimeZoneOffset(Date date)
date - the date represented in milliseconds since January 1, 1970 00:00:00 GMTCopyright © 1998–2023 Apryse Group NV. All rights reserved.