Does anybody know of any plans to support the new java.time api in FreeMarker? Or has anybody code laying around for supporting classes like ZonedDateTime, LocalDateTime and
private static class CustomObjectWrapper extends DefaultObjectWrapper {
@Override
public TemplateModel wrap(Object obj) throws TemplateModelException {
if (obj instanceof LocalDateTime) {
Timestamp timestamp = Timestamp.valueOf((LocalDateTime) obj);
return new SimpleDate(timestamp);
}
if (obj instanceof LocalDate) {
Date date = Date.valueOf((LocalDate) obj);
return new SimpleDate(date);
}
if (obj instanceof LocalTime) {
Time time = Time.valueOf((LocalTime) obj);
return new SimpleDate(time);
}
return super.wrap(obj);
}
}
@Autowired
private freemarker.template.Configuration configuration;
configuration.setObjectWrapper(new CustomObjectWrapper());