public class DateUtils
extends org.apache.commons.lang3.time.DateUtils
| Modifier and Type | Field and Description |
|---|---|
static org.joda.time.format.DateTimeFormatter |
DATE_TIMESTAMP_FORMATTER |
static String |
DFT_DATE_FORMAT |
static String |
DFT_DATE_FORMAT_WITHTIMESTAMP |
static org.joda.time.format.DateTimeFormatter |
FORMAT_DATE_TO_YEAR |
static org.joda.time.format.DateTimeFormatter |
TO_DEFAULT_DATE_FORMAT |
| Modifier and Type | Method and Description |
|---|---|
static Date |
add(Date inputDate,
int addType,
int addAmount)
Adds given number of days/months/years to given date and returns the
resulting date.
|
static boolean |
between(Date date,
Date fromDate,
Date toDate)
Checks if the given date is between the 2 dates
|
static boolean |
compareDates(Date firstDate,
Date secondDate)
This method will return true
if any of the given date is null or firstDate comes before the secondDate or both dates are same will return false if firstDate comes after secondDate |
static Date[] |
constructDateRange(Date fromDate,
Date toDate)
Constructs the Date range for the given From Date and To Date The given
dates will change like following
From date will construct time as 0:0:0 AM To Date will construct time as To Date + 1 [one day advance] 0:0:0. |
static Date[] |
constructDateRange(String fromDate,
String toDate)
Constructs the Date range for the given From Date and To Date value using
default Date Range formatting using DATEFORMATTER value.
The given dates will change like following From date will construct time as 0:0:0 AM To Date will construct time as To Date + 1 [one day advance] 0:0:0. |
static String |
convertToWords(Date dateToConvert)
Converts the given Date to word representation
eg: for 08/12/2008 date converted in to Eighth December Two Thousand Eight . |
static Date |
createDate(int year)
Creates the date.
|
static String |
currentDateToDefaultDateFormat() |
static String |
currentDateToYearFormat() |
static Date |
endOfDay(Date date) |
static org.joda.time.DateTime |
endOfGivenDate(org.joda.time.DateTime dateTime) |
static org.joda.time.DateTime |
endOfToday() |
static Map<Integer,String> |
getAllFinancialYearMonthsWithFullNames() |
static Map<Integer,String> |
getAllMonths()
Gets the all months.
|
static Map<Integer,String> |
getAllMonthsWithFullNames()
Gets all months with full names.
|
static Date |
getDate(int year,
int month,
int date)
Gets the date.
|
static Date |
getDate(String date,
String pattern)
Get the java.util.Date for the given date string value in given pattern.
|
static SimpleDateFormat |
getDateFormatter(String pattern)
Gets the date formatter.
|
static String |
getDefaultFormattedDate(Date date)
Will format the given Date by dd/MM/yyyy pattern.
|
static String |
getFormattedDate(Date date,
String pattern)
Will format the given Date by given pattern.
|
static String |
getFormattedDateWithTimeStamp(org.joda.time.DateTime date)
Will format the given Date by dd/MM/yyyy hh:mm a pattern.
|
static int |
getNumberOfYearPassesed(Date startDate,
Date endDate) |
static Date[] |
getStartAndEndOfDay(Date startDate,
Date endDate) |
static int |
noOfDays(Date startDate,
Date endDate) |
static int |
noOfMonths(Date startDate,
Date endDate) |
static int |
noOfYears(Date startDate,
Date endDate) |
static Date |
now()
Now.
|
static Date |
startOfDay(Date date) |
static org.joda.time.DateTime |
startOfGivenDate(org.joda.time.DateTime dateTime) |
static Date |
today()
Today.
|
static String |
toDefaultDateFormat(Date date) |
static String |
toDefaultDateFormat(org.joda.time.LocalDate date) |
static Date |
tomorrow()
Tomorrow.
|
static String |
toYearFormat(Date date) |
static String |
toYearFormat(org.joda.time.LocalDate date) |
addDays, addHours, addMilliseconds, addMinutes, addMonths, addSeconds, addWeeks, addYears, ceiling, ceiling, ceiling, getFragmentInDays, getFragmentInDays, getFragmentInHours, getFragmentInHours, getFragmentInMilliseconds, getFragmentInMilliseconds, getFragmentInMinutes, getFragmentInMinutes, getFragmentInSeconds, getFragmentInSeconds, isSameDay, isSameDay, isSameInstant, isSameInstant, isSameLocalTime, iterator, iterator, iterator, parseDate, parseDate, parseDateStrictly, parseDateStrictly, round, round, round, setDays, setHours, setMilliseconds, setMinutes, setMonths, setSeconds, setYears, toCalendar, truncate, truncate, truncate, truncatedCompareTo, truncatedCompareTo, truncatedEquals, truncatedEqualspublic static final String DFT_DATE_FORMAT
public static final String DFT_DATE_FORMAT_WITHTIMESTAMP
public static final org.joda.time.format.DateTimeFormatter FORMAT_DATE_TO_YEAR
public static final org.joda.time.format.DateTimeFormatter TO_DEFAULT_DATE_FORMAT
public static final org.joda.time.format.DateTimeFormatter DATE_TIMESTAMP_FORMATTER
public static String currentDateToYearFormat()
public static String toYearFormat(org.joda.time.LocalDate date)
public static String currentDateToDefaultDateFormat()
public static String toDefaultDateFormat(org.joda.time.LocalDate date)
public static org.joda.time.DateTime endOfToday()
public static org.joda.time.DateTime endOfGivenDate(org.joda.time.DateTime dateTime)
public static org.joda.time.DateTime startOfGivenDate(org.joda.time.DateTime dateTime)
public static Date add(Date inputDate, int addType, int addAmount)
inputDate - Input dateaddType - type to be added
(Calendar.DAY_OF_MONTH/Calendar.MONTH/Calendar.YEAR)addAmount - Number of days/months/years to be added to the input datepublic static boolean compareDates(Date firstDate, Date secondDate)
firstDate - secondDate - public static Date[] constructDateRange(Date fromDate, Date toDate)
fromDate - DatetoDate - Date. return Date[] converted Date String values of From Date
and To Datepublic static Date[] constructDateRange(String fromDate, String toDate) throws ParseException
fromDate - StringtoDate - String. return Date[] converted Date String values of From
Date and To DateParseException - the parse exceptionpublic static Date createDate(int year)
year - the yearpublic static Map<Integer,String> getAllMonths()
public static Map<Integer,String> getAllMonthsWithFullNames()
public static Date getDate(String date, String pattern)
public static Date getDate(int year, int month, int date)
year - the yearmonth - the monthdate - the datepublic static String getDefaultFormattedDate(Date date)
date - the datepublic static String getFormattedDate(Date date, String pattern)
date - the datepattern - the patternpublic static Date now()
public static Date today()
public static Date tomorrow()
public static String convertToWords(Date dateToConvert)
dateToConvert - the date to convertpublic static SimpleDateFormat getDateFormatter(String pattern)
pattern - the patternpublic static boolean between(Date date, Date fromDate, Date toDate)
date - fromDate - toDate - public static String getFormattedDateWithTimeStamp(org.joda.time.DateTime date)
date - the dateCopyright © 2015–2017 eGovernments Foundation. All rights reserved.