Package org.pentaho.di.core.util
Class DateDetector
java.lang.Object
org.pentaho.di.core.util.DateDetector
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringdetectDateFormat(String dateString) static StringdetectDateFormat(String dateString, String locale) static StringdetectDateFormatBiased(String dateString, String locale, String desiredKey) Finds a date format that matches the date value given.static StringgetDateFormatByRegex(String regex) static StringgetDateFormatByRegex(String regex, String locale) static org.apache.commons.collections.BidiMapgetDateFormatToRegExps(String locale) static DategetDateFromString(String dateString) static DategetDateFromString(String dateString, String locale) static DategetDateFromStringByFormat(String dateString, String dateFormat) static StringgetRegexpByDateFormat(String dateFormat) static StringgetRegexpByDateFormat(String dateFormat, String locale) static booleanisValidDate(String dateString) static booleanisValidDate(String dateString, String dateFormat) static booleanisValidDateFormatToStringDate(String dateFormat, String dateString) static booleanisValidDateFormatToStringDate(String dateFormat, String dateString, String locale)
-
Method Details
-
getRegexpByDateFormat
- Parameters:
dateFormat- - date format for get regexp- Returns:
- regexp for given date format
-
getRegexpByDateFormat
- Parameters:
dateFormat- - date format for get regexp by locale- Returns:
- regexp for given date format
-
getDateFormatByRegex
- Parameters:
regex- - regexp for parse date format from string
NOTES: if regex could be used for US and EU locale. It returns europeans locale. For en_US locale please usegetDateFormatByRegex(String regex, String locale)- Returns:
Stringstring wich represented Date Format
-
getDateFormatByRegex
- Parameters:
regex- - regexp for parse date format from string by locale- Returns:
Stringstring wich represented Date Format
-
getDateFromString
- Parameters:
dateString- date string for parse- Returns:
Dateconverted from dateString by detected format- Throws:
ParseException- - if we can not detect date format for string or we can not parse date string
-
getDateFromString
- Parameters:
dateString- date string for parse- Returns:
Dateconverted from dateString by detected format- Throws:
ParseException- - if we can not detect date format for string or we can not parse date string
-
getDateFromStringByFormat
public static Date getDateFromStringByFormat(String dateString, String dateFormat) throws ParseException - Parameters:
dateString- date string for parsedateFormat- format which should be applied for string- Returns:
Dateconverted from dateString by format- Throws:
ParseException- if we can not parse date string
-
detectDateFormat
- Parameters:
dateString- - date string for detect date format- Returns:
Stringstring which represented Date Format or null
-
detectDateFormat
- Parameters:
dateString- - date string for detect date format- Returns:
Stringstring which represented Date Format or null
-
detectDateFormatBiased
Finds a date format that matches the date value given. Will try the desiredKey format before attempting others. The first to match is returned.- Parameters:
dateString- the literal value of the date (eg: "01/01/2001")locale- the locale in playdesiredKey- the desired format (should be a valid key to DATE_FORMAT_TO_REGEXPS)- Returns:
- The key to the format that matched or null if none found.
-
getDateFormatToRegExps
-
isValidDate
- Parameters:
dateString- - string for checkdateFormat- - format for check- Returns:
- true if we can parse string by format without exception
-
isValidDate
- Parameters:
dateString- - string for check- Returns:
- true if we can parse string without exception
-
isValidDateFormatToStringDate
- Parameters:
dateFormat- - format which we will try to apply for stringdateString- - string which contains date- Returns:
- true if we found that we know dateFormat and it applied for given string
-
isValidDateFormatToStringDate
public static boolean isValidDateFormatToStringDate(String dateFormat, String dateString, String locale) - Parameters:
dateFormat- - format which we will try to apply for stringdateString- - string which contains datelocale- - locale for date format- Returns:
- true if we found that we know dateFormat and it applied for given string
-