Package org.apache.empire.commons
Class DateUtils
java.lang.Object
org.apache.empire.commons.DateUtils
This class contains common functions for comparing and converting values of type Date.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic DateCalculates a date relative to the supplied date.static longcompareDates(Date date1, Date date2) static booleancompareEqual(Date date1, Date date2) static StringformatDate(LocalDate localDate, Locale locale) static StringformatDate(LocalDateTime localDateTime, Locale locale) static StringformatDate(Date date, Locale locale) static StringformatDateTime(LocalDateTime localDateTime, Locale locale, boolean withSeconds) static StringformatDayOfWeek(int dayOfWeek, Locale locale, boolean longFormat) static StringformatDayOfWeek(Temporal date, Locale locale, boolean longFormat) static StringformatDayOfWeek(Date date, Locale locale, boolean longFormat) static StringformatMonth(int month, Locale locale, boolean longFormat) static StringformatMonth(Temporal date, Locale locale, boolean longFormat) static StringformatMonth(Date date, Locale locale, boolean longFormat) static StringformatTime(Date date, Locale locale, boolean withSeconds) static StringformatYear(Date date, Locale locale) static DategetDate(int year, int month, int day) static DateFormatSymbolsgetDateFormatSymbols(Locale locale) static DateReturns the current date without timestatic DategetDateOnly(Date date) static DategetDateTime(int year, int month, int day, int hours, int minutes, int seconds) static DategetDateTime(int year, int month, int day, int hours, int minutes, int seconds, int millis) static intgetDay()static intstatic intstatic intgetDayOfWeek(Date date) static intgetDaysBetween(Date date1, Date date2) static DateTimeFormattergetLocalDateFormatter(Locale locale) static DateTimeFormattergetLocalDateTimeFormatter(Locale locale, boolean withSeconds) static intgetMonth()static intstatic DateTimeFormattergetPatternFormatter(String pattern) static DateReturns the current date and timestatic DategetTimeOnly(Date date) static TimestampReturns a Timestamp for now() The timstamp's nano seconds will be limited to 6 digits!static intgetWeekOfYear(Date date, Locale locale) static intgetYear()static intstatic Datestatic LocalDateparseLocalDate(String date) static LocalDateparseLocalDate(String date, DateTimeFormatter formatter) static LocalDateTimeparseLocalDateTime(String date) static LocalDateTimeparseLocalDateTime(String date, DateTimeFormatter formatter) static Datestatic Datestatic Datestatic DatetoDate(LocalDateTime localDateTime) static LocalDatetoLocalDate(Date date) static LocalDatetoLocalDate(Timestamp timestamp) static LocalDatetoLocalDate(Date date) static LocalDateTimetoLocalDateTime(Date date) static LocalDateTimetoLocalDateTime(Timestamp timestamp) static LocalDateTimetoLocalDateTime(Date date)
-
Field Details
-
MILLIS_IN_DAY
public static final long MILLIS_IN_DAY- See Also:
-
FORMAT_PATTERN_ISO_DATE
- See Also:
-
FORMAT_PATTERN_ISO_TIME
- See Also:
-
FORMAT_PATTERN_ISO_DATETIME
- See Also:
-
FORMAT_PATTERN_ISO_TIMESTAMP
- See Also:
-
FORMAT_PATTERN_ISO_TIMESTAMP6
- See Also:
-
FORMAT_PATTERN_ISO_TIMESTAMP9
- See Also:
-
-
Method Details
-
getDateNow
Returns the current date without time- Returns:
- the date
-
getTimeNow
Returns the current date and time- Returns:
- the date
-
getTimestamp
Returns a Timestamp for now() The timstamp's nano seconds will be limited to 6 digits!- Returns:
- the Timestamp
-
addDate
Calculates a date relative to the supplied date.- Parameters:
date- date to calculate fromyears- number of years to add or subtract from the supplied datemonths- number of months to add or subtract from the supplied datedays- number of days to add or subtract from the supplied date- Returns:
- the target date
-
setDate
-
getDate
-
getDateTime
public static Date getDateTime(int year, int month, int day, int hours, int minutes, int seconds, int millis) -
getDateTime
-
setTime
-
getDateOnly
-
getTimeOnly
-
compareDates
-
compareEqual
-
getDaysBetween
-
getYear
public static int getYear() -
getYear
-
getMonth
public static int getMonth() -
getMonth
-
getDay
public static int getDay() -
getDay
-
getDayOfWeek
public static int getDayOfWeek() -
getDayOfWeek
-
getWeekOfYear
-
parseDate
-
formatDate
-
formatTime
-
getDateFormatSymbols
-
formatDayOfWeek
-
formatDayOfWeek
-
formatDayOfWeek
-
formatMonth
-
formatMonth
-
formatMonth
-
formatYear
-
toLocalDate
-
toLocalDate
-
toLocalDateTime
-
toLocalDateTime
-
toLocalDate
-
toLocalDateTime
-
toDate
-
toDate
-
parseLocalDate
-
parseLocalDate
-
parseLocalDateTime
-
parseLocalDateTime
-
getPatternFormatter
-
getLocalDateFormatter
-
getLocalDateTimeFormatter
-
formatDate
-
formatDate
-
formatDateTime
public static String formatDateTime(LocalDateTime localDateTime, Locale locale, boolean withSeconds)
-