if (localeUsed == null)
{
localeUsed = getResourceBundleFactory().getLocale();
}
final DateFormat format;
if (dateFormat == null || ObjectUtilities.equal(localeUsed, lastLocale) == false)
{
final String formatString = getFormat();
if (formatString == null || formatString.length() == 0)
{
format = DateFormat.getDateInstance(DateFormat.DEFAULT, localeUsed);
dateFormat = format;
lastLocale = localeUsed;
}
else
{
final SimpleDateFormat sformat = new SimpleDateFormat(formatString);
if (locale != null)
{
sformat.setDateFormatSymbols(new DateFormatSymbols(locale));
}
else
{
final ResourceBundleFactory factory = getResourceBundleFactory();
sformat.setDateFormatSymbols(new DateFormatSymbols(factory.getLocale()));
}
format = sformat;
dateFormat = sformat;
lastLocale = localeUsed;
}
}
else
{
format = dateFormat;
}
if (ObjectUtilities.equal(timeZone, lastTimeZone) == false)
{
lastTimeZone = timeZone;
format.setTimeZone(timeZone);
}
return format.parse(String.valueOf(o));
}
catch (ParseException e)
{
return null;
}