The only way you can do this is with a custom persister. You can then control how ORMLite stores and retrieves data from the database. This feature is [unfortunately] not well documented.
You specify the class like this:
@DatabaseField(persisterClass = MyDatePersister.class)
Date birthDate;
Then your persister class might look like:
public class MyDatePersister extends com.j256.ormlite.field.types.BaseDataType {
private static final MyDatePersister singleTon = new MyDatePersister();
@SuppressWarnings("deprecation")
private static final Timestamp ZERO_TIMESTAMP = new Timestamp(0, 0, 0, 0, 0, 0, 0);
private MyDatePersister() {
super(SqlType.DATE, new Class<?>[] { Date.class });
}
public static MyDatePersister getSingleton() {
return singleTon;
}
@Override
public Object resultToSqlArg(FieldType fieldType, DatabaseResults results,
int columnPos) throws SQLException {
Timestamp timestamp = results.getTimestamp(columnPos);
if (timestamp == null || ZERO_TIMESTAMP.equals(timestamp)) {
return null;
} else {
return timestamp;
}
}
}
DateType source is online. Hope this helps.