#653 - Change format of all Timestamp/Date time types to use epoch millis

This commit is contained in:
Robin Bygrave
2016-04-18 12:49:16 +12:00
parent 2de78cd20f
commit 658ce3c5d3
2 changed files with 30 additions and 5 deletions
@@ -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;
}