*/
public static Date date(String date, String datePattern) {
try {
// String datePattern = "yyyy-MM-dd";
Locale locale = Locale.getDefault();
DateLocaleConverter converter = new DateLocaleConverter(locale,
datePattern);
// It does not accept dates with months greater than 12 and days
// greater than 31.
// It accepts years greater than the current year.
converter.convert(date, datePattern);
SimpleDateFormat formatter = new SimpleDateFormat(datePattern,
locale);
return formatter.parse(date);
} catch (Exception e) {
return null;