if (obj != null) {
// Retrieve the format, pattern and precision associated to
// the type
Class type = field.getType();
String pattern = datafield.pattern();
int precision = datafield.precision();
// Create format
Format format = FormatFactory.getFormat(type, pattern, getLocale(), precision);