Class DateTimeUtil
java.lang.Object
com.itextpdf.commons.utils.DateTimeUtil
This file is a helper class for internal usage only.
Be aware that its API and functionality may be changed in future.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic CalendaraddDaysToCalendar(Calendar calendar, int days) Adds the specified amount of days to the given calendar field.static DateaddDaysToDate(Date date, int days) Adds the specified amount of days to the given date.static DateaddMillisToDate(Date date, long millis) Adds provided number of milliseconds to the Date.static DateaddYearsToDate(Date date, int years) Adds the specified amount of years to the given date.static StringdateToString(Calendar date) ConvertsCalendardate to string of "yyyy.MM.dd HH:mm:ss z" format.static StringFormat passing date with specified pattern.static StringformatWithDefaultPattern(Date date) Format passing date with default yyyy-MM-dd pattern.static CalendargetCalendar(Date date) Gets the date asCalendar.static CalendarGets a defaultGregorianCalendar.static DateGets current time consistently.static longgetCurrentTimeZoneOffset(Date date) Gets the offset of time zone from UTC at the specified date.static longgetRelativeTime(Date date) Gets the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by specified date.static doublegetUtcMillisFromEpoch(Calendar calendar) Gets theCalendaras UTC milliseconds from the epoch.private static DateFormatinitParserSDF(String pattern) static booleanDefines if date is in past.static DateParses passing date with specified format.static DateParses passing date with default yyyy-MM-dd pattern.
-
Field Details
-
DEFAULT_PATTERN
- See Also:
-
-
Constructor Details
-
DateTimeUtil
private DateTimeUtil()
-
-
Method Details
-
getUtcMillisFromEpoch
-
getCalendar
-
getCurrentTimeCalendar
Gets a defaultGregorianCalendar.- Returns:
- a default
GregorianCalendarusing the current time in the default time zone with the default locale
-
getCurrentTimeDate
Gets current time consistently.- Returns:
- the time at which it was allocated, measured to the nearest millisecond
-
addDaysToCalendar
Adds the specified amount of days to the given calendar field.- Parameters:
calendar- the calendar field where to adddays- the amount of days to be added- Returns:
- the time at which it was allocated, measured to the nearest millisecond
-
isInPast
Defines if date is in past.- Parameters:
date- the date to be compared with current date- Returns:
trueif given date is in past,falseinstead
-
getRelativeTime
Gets the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by specified date.- Parameters:
date- the specified date to get time- Returns:
- the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by the specified date
-
addMillisToDate
-
addDaysToDate
-
addYearsToDate
-
parseWithDefaultPattern
-
parse
-
formatWithDefaultPattern
-
format
-
getCurrentTimeZoneOffset
Gets the offset of time zone from UTC at the specified date.- Parameters:
date- the date represented in milliseconds since January 1, 1970 00:00:00 GMT- Returns:
- the offset of time zone from UTC at the specified date adjusted with the amount of daylight saving.
-
dateToString
-
initParserSDF
-