Class DateHelper
java.lang.Object
org.eclipse.nebula.widgets.calendarcombo.DateHelper
public class DateHelper
extends java.lang.Object
-
Constructor Summary
Constructors Constructor Description DateHelper()
-
Method Summary
Modifier and Type Method 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.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 java.lang.String
getDate(java.util.Calendar cal, java.lang.String dateFormat)
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.
-
Constructor Details
-
DateHelper
public DateHelper()
-
-
Method Details
-
daysBetween
public static long daysBetween(java.util.Calendar start, java.util.Calendar end, java.util.Locale locale) -
daysBetween
public static long daysBetween(java.util.Date start, java.util.Date end, java.util.Locale locale) -
isToday
public static boolean isToday(java.util.Date date, java.util.Locale locale) -
isToday
public static boolean isToday(java.util.Calendar cal, java.util.Locale locale) -
getDate
public static java.lang.String getDate(java.util.Calendar cal, java.lang.String dateFormat) -
sameDate
public static boolean sameDate(java.util.Date date1, java.util.Date date2, java.util.Locale locale) -
sameDate
public static boolean sameDate(java.util.Calendar cal1, java.util.Calendar cal2) -
getDate
public static java.util.Date getDate(java.lang.String str, java.lang.String dateFormat) throws java.lang.Exception- Throws:
java.lang.Exception
-
getDate
public static java.util.Calendar getDate(java.lang.String str, java.lang.String dateFormat, java.util.Locale locale) throws java.lang.Exception- Throws:
java.lang.Exception
-
parseDate
public static java.util.Calendar parseDate(java.lang.String str, java.util.Locale locale) throws java.lang.Exception- Throws:
java.lang.Exception
-
parse
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- Throws:
CalendarDateParseException
java.lang.Exception
-
parseDateHard
public static java.util.Calendar parseDateHard(java.lang.String str, java.util.Locale locale) throws CalendarDateParseException, java.lang.ExceptionThis method will try its best to parse a date based on the current Locale.- Parameters:
str
- String to parselocale
- Current Locale- Returns:
- Calendar or null on failure
- Throws:
CalendarDateParseException
- If date could not be parsedjava.lang.Exception
- on any unforseen issues or bad parse errors
-
dateFormatFix
public static java.lang.String dateFormatFix(java.lang.String str) -
numericParse
public static java.util.Calendar numericParse(java.lang.String str, java.util.Locale locale, boolean doUsEuParse) throws java.lang.Exception- Throws:
java.lang.Exception
-
getCalendarTypeForString
public static int getCalendarTypeForString(java.lang.String oneChar) -
slashParse
public static java.util.Calendar slashParse(java.lang.String str, java.lang.String dateFormat, char[] separators, java.util.Locale locale) throws CalendarDateParseException, java.lang.ExceptionThis 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. This is by no means a foolproof method and should not be relied upon returning 100% correct dates all the time.- Parameters:
str
- String to parsedateFormat
- DateFormat to useseparators
- Separator chars that can be encounteredlocale
- Locale- Returns:
- Calendar
- Throws:
CalendarDateParseException
- If date could not be parsedjava.lang.Exception
- If any step of the parsing failed
-