public class DateHelper
extends java.lang.Object
Constructor and Description |
---|
DateHelper() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
dateFormatFix(java.lang.String str) |
static long |
daysBetween(java.util.Calendar start,
java.util.Calendar end,
java.util.Locale locale) |
static long |
daysBetween(java.util.Date start,
java.util.Date end,
java.util.Locale locale) |
static int |
getCalendarTypeForString(java.lang.String oneChar) |
static java.lang.String |
getDate(java.util.Calendar cal,
java.lang.String dateFormat) |
static java.util.Date |
getDate(java.lang.String str,
java.lang.String dateFormat) |
static java.util.Calendar |
getDate(java.lang.String str,
java.lang.String dateFormat,
java.util.Locale locale) |
static boolean |
isToday(java.util.Calendar cal,
java.util.Locale locale) |
static boolean |
isToday(java.util.Date date,
java.util.Locale locale) |
static java.util.Calendar |
numericParse(java.lang.String str,
java.util.Locale locale,
boolean doUsEuParse) |
static java.util.Calendar |
parse(java.lang.String comboText,
java.util.Locale locale,
java.lang.String dateFormat,
char[] acceptedSeparatorChars,
java.util.List additionalDateFormats) |
static java.util.Calendar |
parseDate(java.lang.String str,
java.util.Locale locale) |
static java.util.Calendar |
parseDateHard(java.lang.String str,
java.util.Locale locale)
This method will try its best to parse a date based on the current
Locale.
|
static boolean |
sameDate(java.util.Calendar cal1,
java.util.Calendar cal2) |
static boolean |
sameDate(java.util.Date date1,
java.util.Date date2,
java.util.Locale locale) |
static java.util.Calendar |
slashParse(java.lang.String str,
java.lang.String dateFormat,
char[] separators,
java.util.Locale locale)
This method assumes the dateFormat has a separator char in it, and that
we can use that to determine what the user entered by using that
separator to split up the user entered date, and then do some logic on
it.
|
public static long daysBetween(java.util.Calendar start, java.util.Calendar end, java.util.Locale locale)
public static long daysBetween(java.util.Date start, java.util.Date end, java.util.Locale locale)
public static boolean isToday(java.util.Date date, java.util.Locale locale)
public static boolean isToday(java.util.Calendar cal, java.util.Locale locale)
public static java.lang.String getDate(java.util.Calendar cal, java.lang.String dateFormat)
public static boolean sameDate(java.util.Date date1, java.util.Date date2, java.util.Locale locale)
public static boolean sameDate(java.util.Calendar cal1, java.util.Calendar cal2)
public static java.util.Date getDate(java.lang.String str, java.lang.String dateFormat) throws java.lang.Exception
java.lang.Exception
public static java.util.Calendar getDate(java.lang.String str, java.lang.String dateFormat, java.util.Locale locale) throws java.lang.Exception
java.lang.Exception
public static java.util.Calendar parseDate(java.lang.String str, java.util.Locale locale) throws java.lang.Exception
java.lang.Exception
public static java.util.Calendar parse(java.lang.String comboText, java.util.Locale locale, java.lang.String dateFormat, char[] acceptedSeparatorChars, java.util.List additionalDateFormats) throws CalendarDateParseException, java.lang.Exception
CalendarDateParseException
java.lang.Exception
public static java.util.Calendar parseDateHard(java.lang.String str, java.util.Locale locale) throws CalendarDateParseException, java.lang.Exception
str
- String to parselocale
- Current LocaleCalendarDateParseException
- If date could not be parsedjava.lang.Exception
- on any unforseen issues or bad parse errorspublic static java.lang.String dateFormatFix(java.lang.String str)
public static java.util.Calendar numericParse(java.lang.String str, java.util.Locale locale, boolean doUsEuParse) throws java.lang.Exception
java.lang.Exception
public static int getCalendarTypeForString(java.lang.String oneChar)
public static java.util.Calendar slashParse(java.lang.String str, java.lang.String dateFormat, char[] separators, java.util.Locale locale) throws CalendarDateParseException, java.lang.Exception
str
- String to parsedateFormat
- DateFormat to useseparators
- Separator chars that can be encounteredlocale
- LocaleCalendarDateParseException
- If date could not be parsedjava.lang.Exception
- If any step of the parsing failed