@Override
public Object fromString(final String str) {
final int idx = str.lastIndexOf('.');
if (idx < 0 || str.length() - idx < 2 || str.length() - idx > 10) {
throw new ConversionException("Timestamp format must be yyyy-mm-dd hh:mm:ss[.fffffffff]");
}
try {
final Timestamp timestamp = new Timestamp(format.parse(str.substring(0, idx)).getTime());
final StringBuilder buffer = new StringBuilder(str.substring(idx + 1));
while (buffer.length() != 9) {
buffer.append('0');
}
timestamp.setNanos(Integer.parseInt(buffer.toString()));
return timestamp;
} catch (final NumberFormatException e) {
throw new ConversionException("Timestamp format must be yyyy-mm-dd hh:mm:ss[.fffffffff]", e);
} catch (final ParseException e) {
throw new ConversionException("Timestamp format must be yyyy-mm-dd hh:mm:ss[.fffffffff]");
}
}