I dove into ERXRestUtils with limited (well, no) success—it’s not clear to me how/when these methods are used. Since I only need this working on the output side for now, I extended ERXJSONRestWriter to register a custom JsonValueProcessor class for the LocalTime type:
@Override
protected JsonConfig configWithContext(ERXRestContext context) {
JsonConfig result = super.configWithContext(context);
result.registerJsonValueProcessor(LocalTime.class,
new LocalTimeProcessor(context));
return result;
}
LocalTimeProcessor then implements:
@Override
public Object processArrayValue(Object value, JsonConfig config) {
if (value == null) {
return null;
} else {
DateTimeFormatter fmt = DateTimeFormat.forPattern("HH:mm");
return fmt.print((LocalTime) value);
}
}
@Override
public Object processObjectValue(String key, Object value,
JsonConfig config) {
return processArrayValue(value, config);
}
And I then register the new writer in didFinishLaunching():
ERXRestFormat.registerFormatNamed(new ERXJSONRestParser(),
new LSJSONRestWriter(), new ERXRestFormatDelegate(),
ERXRestFormat.JSON_KEY, "application/json");