Post

Json-Lib(net.sf.json) Serialize Jodatime LocalDate

1
2
3
4
5
6
7
8
9
JsonConfig jsonConfig = new JsonConfig();
jsonConfig.registerJsonValueProcessor(LocalDate.class, new JsDateJsonValueProcessor() {
	@Override
	public Object processObjectValue(String key, Object value, JsonConfig jsonConfig) {
		return ((LocalDate) value).toString("yyyy-MM-dd");
	}
});

JSONObject.fromObject(resultMap, jsonConfig).toString();
This post is licensed under CC BY 4.0 by the author.