Class DateUtil
java.lang.Object
org.eclipse.nebula.widgets.xviewer.util.internal.DateUtil
public class DateUtil
extends java.lang.Object
-
Field Summary
Fields 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
Constructors Constructor Description DateUtil()
-
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)
-
Field Details
-
MILLISECONDS_IN_A_WEEK
public static final long MILLISECONDS_IN_A_WEEK- See Also:
- Constant Field Values
-
MILLISECONDS_IN_A_DAY
public static final long MILLISECONDS_IN_A_DAY- See Also:
- Constant Field Values
-
MMDDYY
public static final java.lang.String MMDDYY- See Also:
- Constant Field Values
-
YYYYMMDD
public static final java.lang.String YYYYMMDD- See Also:
- Constant Field Values
-
YYYY_MM_DD
public static final java.lang.String YYYY_MM_DD- See Also:
- Constant Field Values
-
YYYY_MM_DD_WITH_DASHES
public static final java.lang.String YYYY_MM_DD_WITH_DASHES- See Also:
- Constant Field Values
-
MMDDYYHHMM
public static final java.lang.String MMDDYYHHMM- See Also:
- Constant Field Values
-
HHMMSS
public static final java.lang.String HHMMSS- See Also:
- Constant Field Values
-
HHMMSSSS
public static final java.lang.String HHMMSSSS- See Also:
- Constant Field Values
-
HHMM
public static final java.lang.String HHMM- See Also:
- Constant Field Values
-
dateFormats
public static final java.util.HashMap<java.lang.String,java.text.DateFormat> dateFormats
-
-
Constructor Details
-
DateUtil
public DateUtil()
-
-
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- 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) -
getMMDDYYHHMM
public static java.lang.String getMMDDYYHHMM() -
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)- Parameters:
startDate
- The first date of the interpolation. MUST be before endDate.endDate
- The last date of the interpolation. MUST be after startDateinterDate
- The date between startDate and endDate.- Returns:
- 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)- Returns:
- [date] + [manyWeeks]
-
getManyWeeksDifference
public static int getManyWeeksDifference(java.util.Date a, java.util.Date b)- Parameters:
a
- One date. Sequential order with other date parameter does not matter.b
- Another date. Sequential order with other date parameter does not matter.- Returns:
- the number of weeks difference between Date a and Date b.
-
getMondayBefore
public static java.util.Date getMondayBefore(java.util.Date date)- Returns:
- 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)- Returns:
- 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)- Returns:
- The same date but with time equal to 00:00:00
-
convertToEndOfDay
public static java.util.Date convertToEndOfDay(java.util.Date date)- Returns:
- The same date but with time equal to 23:59:59
-
getSentinalDate
public static java.util.Date getSentinalDate()- Returns:
- Jan 1, 2001 1:1:1
-