mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#653 - Change format of all Timestamp/Date time types to use epoch millis
This commit is contained in:
@@ -131,14 +131,20 @@ public abstract class ScalarTypeBaseDateTime<T> extends ScalarTypeBase<T> {
|
||||
}
|
||||
|
||||
public String formatValue(T value) {
|
||||
return convertToTimestamp(value).toString();
|
||||
// format all timestamps into epoch millis
|
||||
long epochMillis = convertToMillis(value);
|
||||
return Long.toString(epochMillis);
|
||||
}
|
||||
|
||||
public T parse(String value) {
|
||||
return convertFromTimestamp(Timestamp.valueOf(value));
|
||||
try {
|
||||
long epochMillis = Long.parseLong(value);
|
||||
return convertFromMillis(epochMillis);
|
||||
} catch (NumberFormatException e) {
|
||||
return convertFromTimestamp(Timestamp.valueOf(value));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean isDateTimeCapable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user