|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jminor.common.model.DateUtil
public final class DateUtil
A static utility class for date handling.
Method Summary | |
---|---|
static Date |
floorDate(Date date)
|
static Timestamp |
floorTimestamp(Timestamp timestamp)
|
static Date |
getDate(int year,
int month,
int day)
|
static String |
getDateMask(SimpleDateFormat format)
Parses the date pattern and returns mask string that can be used in JFormattedFields. |
static Date |
getFirstDayOfLastMonth()
|
static Date |
getFirstDayOfMonth(int toAdd)
|
static Date |
getFirstDayOfQuarter(int quarter)
Returns the first day of the the given quarter, assuming quarters begin in january, april, july and october. |
static Date |
getFirstDayOfYear()
|
static Date |
getLastDayOfLastMonth()
|
static Date |
getLastDayOfMonth(int toAdd)
|
static Date |
getLastDayOfQuarter(int quarter)
Returns the last day of the the given quarter, assuming quarters begin in january, april, july and october. |
static Date |
getLastDayOfYear()
|
static ThreadLocal<DateFormat> |
getThreadLocalDateFormat(String formatString)
|
static Date |
getYesterday()
|
static boolean |
isDateValid(String dateString,
boolean emptyStringOk,
DateFormat... formats)
|
static boolean |
isDateValid(String date,
DateFormat... formats)
|
static int |
numberOfDaysInRange(Date from,
Date to)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static boolean isDateValid(String date, DateFormat... formats)
date
- the date to check for validityformats
- the date formats to use for validation
public static boolean isDateValid(String dateString, boolean emptyStringOk, DateFormat... formats)
dateString
- the date to check for validityemptyStringOk
- if true then an empty string is regarded as a valid dateformats
- the date formats to use for validation
public static Date floorDate(Date date)
date
- the Date object to floor
timestamp
except the Calendar.SECOND and Calendar.MILLISECOND fields are set to zeropublic static Timestamp floorTimestamp(Timestamp timestamp)
timestamp
- the Timestamp object to floor
timestamp
except the Calendar.SECOND and Calendar.MILLISECOND fields are set to zeropublic static Date getDate(int year, int month, int day)
year
- the yearmonth
- the monthday
- the day
public static Date getYesterday()
public static Date getFirstDayOfLastMonth()
public static Date getLastDayOfLastMonth()
public static Date getFirstDayOfMonth(int toAdd)
toAdd
- the number of months to add to the current month
toAdd
from the current monthpublic static Date getLastDayOfMonth(int toAdd)
toAdd
- the number of months to add to the current month
toAdd
from the current monthpublic static Date getFirstDayOfYear()
public static Date getLastDayOfYear()
public static Date getFirstDayOfQuarter(int quarter)
quarter
- the quarter, 1, 2, 3 or 4
public static Date getLastDayOfQuarter(int quarter)
quarter
- the quarter, 1, 2, 3 or 4
public static int numberOfDaysInRange(Date from, Date to)
from
- the from dateto
- the to date
public static ThreadLocal<DateFormat> getThreadLocalDateFormat(String formatString)
formatString
- the format string
public static String getDateMask(SimpleDateFormat format)
format
- the SimpleDateFormat for which to retrieve the date mask
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |