Class DateUtil


public class DateUtil
extends java.lang.Object
  • Field Summary

    Modifier and Type Field Description
    static java.util.HashMap<java.lang.String,​java.text.DateFormat> dateFormats  
    static java.lang.String HHMM  
    static java.lang.String HHMMSS  
    static java.lang.String HHMMSSSS  
    static long MILLISECONDS_IN_A_DAY  
    static long MILLISECONDS_IN_A_WEEK  
    static java.lang.String MMDDYY  
    static java.lang.String MMDDYYHHMM  
    static java.lang.String YYYY_MM_DD  
    static java.lang.String YYYY_MM_DD_WITH_DASHES  
    static java.lang.String YYYYMMDD  
  • Constructor Summary

    Constructor Description
  • Method Summary

    Modifier and Type Method Description
    static java.util.Date addWeeks​(java.util.Date date, int manyWeeks)  
    static java.util.Date convertToEndOfDay​(java.util.Date date)  
    static java.util.Date convertToStartOfDay​(java.util.Date date)  
    static java.lang.String get​(java.util.Date date)  
    static java.lang.String get​(java.util.Date date, java.lang.String pattern)  
    static java.lang.String get​(java.util.Date date, java.text.DateFormat dateFormat)  
    static java.util.Calendar getCalendar​(java.util.Date date)  
    static java.util.Date getDate​(java.lang.String format, java.lang.String value)  
    static java.lang.String getDateNow()  
    static java.lang.String getDateNow​(java.lang.String format)  
    static java.lang.String getDateNow​(java.util.Date date)  
    static java.lang.String getDateNow​(java.util.Date date, java.lang.String format)  
    static java.lang.String getDateStr​(java.util.Date date, java.lang.String format)  
    static int getDifference​(java.util.Date a, java.util.Date b)  
    static java.lang.String getHHMM​(java.util.Date date)  
    static java.lang.String getHHMMSS​(java.util.Date date)  
    static double getInterpolationRatioBetweenDates​(java.util.Date startDate, java.util.Date endDate, java.util.Date interDate)  
    static int getManyWeeksDifference​(java.util.Date a, java.util.Date b)  
    static java.lang.String getMMDDYY​(java.util.Date date)  
    static java.lang.String getMMDDYYHHMM()  
    static java.lang.String getMMDDYYHHMM​(java.util.Date date)  
    static java.util.Date getMondayAfter​(java.util.Date date)  
    static java.util.Date getMondayBefore​(java.util.Date date)  
    static java.util.Date getSentinalDate()  
    static java.lang.String getTimeStamp()  
    static int getWorkingDaysBetween​(java.util.Calendar fromDate, java.util.Calendar toDate)  
    static int getWorkingDaysBetween​(java.util.Date fromDate, java.util.Date toDate)  
    static java.lang.String getYYYYMMDD()  
    static java.lang.String getYYYYMMDD​(java.util.Date date)  
    static boolean isWeekDay​(java.util.Calendar cal)  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • getCalendar

      public static java.util.Calendar getCalendar​(java.util.Date date)
    • getWorkingDaysBetween

      public static int getWorkingDaysBetween​(java.util.Date fromDate, java.util.Date toDate)
    • isWeekDay

      public static boolean isWeekDay​(java.util.Calendar cal)
    • getDate

      public static java.util.Date getDate​(java.lang.String format, java.lang.String value) throws java.text.ParseException
    • getWorkingDaysBetween

      public static int getWorkingDaysBetween​(java.util.Calendar fromDate, java.util.Calendar toDate)
    • getHHMM

      public static java.lang.String getHHMM​(java.util.Date date)
    • getHHMMSS

      public static java.lang.String getHHMMSS​(java.util.Date date)
    • getYYYYMMDD

      public static java.lang.String getYYYYMMDD()
    • getYYYYMMDD

      public static java.lang.String getYYYYMMDD​(java.util.Date date)
    • getMMDDYY

      public static java.lang.String getMMDDYY​(java.util.Date date)

      public static java.lang.String getMMDDYYHHMM()

      public static java.lang.String getMMDDYYHHMM​(java.util.Date date)
    • getDateNow

      public static java.lang.String getDateNow()
    • getDateNow

      public static java.lang.String getDateNow​(java.util.Date date)
    • getTimeStamp

      public static java.lang.String getTimeStamp()
    • getDateStr

      public static java.lang.String getDateStr​(java.util.Date date, java.lang.String format)
    • getDateNow

      public static java.lang.String getDateNow​(java.lang.String format)
    • getDateNow

      public static java.lang.String getDateNow​(java.util.Date date, java.lang.String format)
    • get

      public static java.lang.String get​(java.util.Date date)
    • get

      public static java.lang.String get​(java.util.Date date, java.lang.String pattern)
    • get

      public static java.lang.String get​(java.util.Date date, java.text.DateFormat dateFormat)
    • getDifference

      public static int getDifference​(java.util.Date a, java.util.Date b)
    • getInterpolationRatioBetweenDates

      public static double getInterpolationRatioBetweenDates​(java.util.Date startDate, java.util.Date endDate, java.util.Date interDate)
      startDate - The first date of the interpolation. MUST be before endDate.
      endDate - The last date of the interpolation. MUST be after startDate
      interDate - The date between startDate and endDate.
      The interpolation ratio of interDate between startDate and endDate. Where if interDate <= startDate then return 0.0 and if interDate >= endDate return 1.0.
    • addWeeks

      public static java.util.Date addWeeks​(java.util.Date date, int manyWeeks)
      [date] + [manyWeeks]
    • getManyWeeksDifference

      public static int getManyWeeksDifference​(java.util.Date a, java.util.Date b)
      a - One date. Sequential order with other date parameter does not matter.
      b - Another date. Sequential order with other date parameter does not matter.
      the number of weeks difference between Date a and Date b.
    • getMondayBefore

      public static java.util.Date getMondayBefore​(java.util.Date date)
      The date that is the Monday before the date. If the provided date is Monday then it will be returned as-is.
    • getMondayAfter

      public static java.util.Date getMondayAfter​(java.util.Date date)
      The date that is the Monday after the date. If the provided date is Monday then it will be returned as-is.
    • convertToStartOfDay

      public static java.util.Date convertToStartOfDay​(java.util.Date date)
      The same date but with time equal to 00:00:00
    • convertToEndOfDay

      public static java.util.Date convertToEndOfDay​(java.util.Date date)
      The same date but with time equal to 23:59:59
    • getSentinalDate

      public static java.util.Date getSentinalDate()
      Jan 1, 2001 1:1:1