String convertFormat = new String("");
String convertFunction = new String("");
if (! myMetaData.hasField(fieldName))
{
throw new PersistenceException("(" + getName() + ") No such field as " + fieldName);
}
if (getField(fieldName) == null)
{
return null;
}
if (getField(fieldName).equals(""))
{
return null;
}
String myType = myMetaData.getType(fieldName);
if (myType.equalsIgnoreCase("date"))
{
convertFormat = myMetaData.getDatabaseType().getDateUpdateFormat();
convertFunction = myMetaData.getDatabaseType().getDateUpdateFunction();
}
else if (myType.equalsIgnoreCase("datetime") || myType.equalsIgnoreCase("timestamp"))
{
convertFormat = myMetaData.getDatabaseType().getDateTimeUpdateFormat();
convertFunction = myMetaData.getDatabaseType().getDateTimeUpdateFunction();
}
else if (myType.equalsIgnoreCase("time"))
{
convertFormat = myMetaData.getDatabaseType().getTimeUpdateFormat();
convertFunction = myMetaData.getDatabaseType().getTimeUpdateFunction();
}
else
{
throw new PersistenceException("Field '" + fieldName + "' is not a date, datetime or time - it is a "
+ myType + ", which cannot be formatted " + "as a Date/Time type");
}
convertFormat = SuperString.notNull(convertFormat);
convertFunction = SuperString.notNull(convertFunction);
/* If no format was specified, don't change the existing field */
if (convertFormat.equals(""))
{
if (! convertFunction.equals(""))
{
return SuperString.replace(convertFunction, "%s", "'" + getField(fieldName) + "'");
}
else
{
return "'" + getField(fieldName) + "'";
}
}
String returnValue = null;
SimpleDateFormat formatter = new SimpleDateFormat(convertFormat);
returnValue = "'" + formatter.format(originalDate) + "'";
if (returnValue == null)
{
throw new PersistenceException("(" + getName() + ") Unable to format date value from field " + fieldName
+ ", value was " + getField(fieldName));
}
if (! convertFunction.equals(""))
{