public Object getValue() {
final DataRow dataRow = getDataRow();
// get the row directly as a Number
final Object o = dataRow.get(field);
// check if that thing is a Number
if (o instanceof Date)
{
return o;
}
// get a string and convert
try
{
Locale localeUsed = locale;
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;
}
return format.parse(String.valueOf(o));
}
catch (ParseException e)
{
return null;
}
}
Parses the value read from the column specified by the given field-name and tries to parse it into a Date
using the given SimpleDateFormat-pattern. |