Class DateUtils

java.lang.Object
org.apache.empire.commons.DateUtils

public class DateUtils extends Object
This class contains common functions for comparing and converting values of type Date.
  • Field Details

  • Method Details

    • getDateNow

      public static Date getDateNow()
      Returns the current date without time
      Returns:
      the date
    • getTimeNow

      public static Date getTimeNow()
      Returns the current date and time
      Returns:
      the date
    • getTimestamp

      public static Timestamp getTimestamp()
      Returns a Timestamp for now() The timstamp's nano seconds will be limited to 6 digits!
      Returns:
      the Timestamp
    • addDate

      public static Date addDate(Date date, int years, int months, int days)
      Calculates a date relative to the supplied date.
      Parameters:
      date - date to calculate from
      years - number of years to add or subtract from the supplied date
      months - number of months to add or subtract from the supplied date
      days - number of days to add or subtract from the supplied date
      Returns:
      the target date
    • setDate

      public static Date setDate(Date date, int year, int month, int day)
    • getDate

      public static Date getDate(int year, int month, int day)
    • getDateTime

      public static Date getDateTime(int year, int month, int day, int hours, int minutes, int seconds, int millis)
    • getDateTime

      public static Date getDateTime(int year, int month, int day, int hours, int minutes, int seconds)
    • setTime

      public static Date setTime(Date date, int hours, int minutes, int seconds, int millis)
    • getDateOnly

      public static Date getDateOnly(Date date)
    • getTimeOnly

      public static Date getTimeOnly(Date date)
    • compareDates

      public static long compareDates(Date date1, Date date2)
    • compareEqual

      public static boolean compareEqual(Date date1, Date date2)
    • getDaysBetween

      public static int getDaysBetween(Date date1, Date date2)
    • getYear

      public static int getYear()
    • getYear

      public static int getYear(Date date)
    • getMonth

      public static int getMonth()
    • getMonth

      public static int getMonth(Date date)
    • getDay

      public static int getDay()
    • getDay

      public static int getDay(Date date)
    • getDayOfWeek

      public static int getDayOfWeek()
    • getDayOfWeek

      public static int getDayOfWeek(Date date)
    • getWeekOfYear

      public static int getWeekOfYear(Date date, Locale locale)
    • parseDate

      public static Date parseDate(String sDate, Locale locale)
    • formatDate

      public static String formatDate(Date date, Locale locale)
    • formatTime

      public static String formatTime(Date date, Locale locale, boolean withSeconds)
    • getDateFormatSymbols

      public static DateFormatSymbols getDateFormatSymbols(Locale locale)
    • formatDayOfWeek

      public static String formatDayOfWeek(Date date, Locale locale, boolean longFormat)
    • formatDayOfWeek

      public static String formatDayOfWeek(Temporal date, Locale locale, boolean longFormat)
    • formatDayOfWeek

      public static String formatDayOfWeek(int dayOfWeek, Locale locale, boolean longFormat)
    • formatMonth

      public static String formatMonth(Date date, Locale locale, boolean longFormat)
    • formatMonth

      public static String formatMonth(Temporal date, Locale locale, boolean longFormat)
    • formatMonth

      public static String formatMonth(int month, Locale locale, boolean longFormat)
    • formatYear

      public static String formatYear(Date date, Locale locale)
    • toLocalDate

      public static LocalDate toLocalDate(Date date)
    • toLocalDate

      public static LocalDate toLocalDate(Timestamp timestamp)
    • toLocalDateTime

      public static LocalDateTime toLocalDateTime(Date date)
    • toLocalDateTime

      public static LocalDateTime toLocalDateTime(Timestamp timestamp)
    • toLocalDate

      public static LocalDate toLocalDate(Date date)
    • toLocalDateTime

      public static LocalDateTime toLocalDateTime(Date date)
    • toDate

      public static Date toDate(LocalDate localDate)
    • toDate

      public static Date toDate(LocalDateTime localDateTime)
    • parseLocalDate

      public static LocalDate parseLocalDate(String date)
    • parseLocalDate

      public static LocalDate parseLocalDate(String date, DateTimeFormatter formatter)
    • parseLocalDateTime

      public static LocalDateTime parseLocalDateTime(String date)
    • parseLocalDateTime

      public static LocalDateTime parseLocalDateTime(String date, DateTimeFormatter formatter)
    • getPatternFormatter

      public static DateTimeFormatter getPatternFormatter(String pattern)
    • getLocalDateFormatter

      public static DateTimeFormatter getLocalDateFormatter(Locale locale)
    • getLocalDateTimeFormatter

      public static DateTimeFormatter getLocalDateTimeFormatter(Locale locale, boolean withSeconds)
    • formatDate

      public static String formatDate(LocalDate localDate, Locale locale)
    • formatDate

      public static String formatDate(LocalDateTime localDateTime, Locale locale)
    • formatDateTime

      public static String formatDateTime(LocalDateTime localDateTime, Locale locale, boolean withSeconds)