public final class DateUtil extends Object
| Constructor and Description |
|---|
DateUtil() |
| Modifier and Type | Method and Description |
|---|---|
static String |
getAsISODateString(Date date)
Returns the date in ISO 8601 format yyyy-MM-dd.
|
static String |
getAsISODateTimeString(Date date)
Returns the date and time in ISO 8601 format yyyy-MM-dd HH:mm:ss
|
static Date |
getDateFromString(String dateStr)
Tries to match common patterns by which date is mentioned, and returns a Date object.
|
static Date |
getDatePlusDays(Date date,
int days)
Adds the number of days to the date and returns the new Date instance.
|
static Date |
getDatePlusMonths(Date date,
int months)
Adds the number of months to the date and returns the new Date instance.
|
static Date |
getDatePlusYears(Date date,
int years)
Adds the number of years to the date and returns the new Date instance.
|
static Date |
getFromISODateString(String dateStr)
Returns java.util.Date object for the ISO 8601 formatted String yyyy-MM-dd.
|
static boolean |
isDateBetween(Date startDate,
Date endDate,
Date date)
This is an inclusive method: returns true if the date is equal to startDate or endDate.
|
static Date |
now() |
public static String getAsISODateString(Date date)
date - public static String getAsISODateTimeString(Date date)
date - public static Date getFromISODateString(String dateStr)
dateStr - public static boolean isDateBetween(Date startDate, Date endDate, Date date)
startDate - The start date.endDate - The end date.date - The date to verify.public static Date getDatePlusDays(Date date, int days)
date - Input date.days - Number of days to add.public static Date getDatePlusMonths(Date date, int months)
date - Input date.months - Number of months to add.public static Date getDatePlusYears(Date date, int years)
date - Input date.years - Number of years to add.public static Date getDateFromString(String dateStr) throws ParseException
dateStr - The date in common pattern.ParseException - Thrown when not able to parse the date string.public static Date now()
Copyright © 2014. All rights reserved.