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 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()
Deprecated.
Unused and will be removed in the next major release. Use
getCurrentTimeZoneOffset(Date) instead.
|
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 millis
public static Calendar getCurrentTimeCalendar()
GregorianCalendar
.
GregorianCalendar
using the current time in the default time zone with the default locale
public static Date getCurrentTimeDate()
public static Calendar addDaysToCalendar(Calendar calendar, int days)
calendar
- the calendar field where to add
days
- the amount of days to be added
public static boolean isInPast(Date date)
date
- the date to be compared with current date
true
if given date is in past, false
instead
public static long getRelativeTime(Date date)
date
- the specified date to get time
public static Date addDaysToDate(Date date, int days)
date
- the specified date to add
days
- the amount of days to be added
Date
object representing the calendar's time value (millisecond offset from the Epoch)
public static Date parseWithDefaultPattern(String date)
date
- is date to be parse
public static Date parse(String date, String format)
date
- the date to be parsed
format
- the format of parsing the date
public static String formatWithDefaultPattern(Date date)
date
- the date to be formatted
public static String format(Date date, String pattern)
date
- date to be formatted
pattern
- pattern for format
@Deprecated public static long getCurrentTimeZoneOffset()
getCurrentTimeZoneOffset(Date)
instead.
public static long getCurrentTimeZoneOffset(Date date)
date
- the date represented in milliseconds since January 1, 1970 00:00:00 GMT
Copyright © 1998–2022 iText Group NV. All rights reserved.