Skip to content

Commit 2ab482a

Browse files
authored
Merge pull request #491 from user667/bug/9753-fix-date-handling-JacksonConfig.mustache-template
Fix dateLibrary=java8 handling in JacksonConfig.mustache #9753
2 parents e9937d9 + 7d5f61f commit 2ab482a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/main/resources/handlebars/JavaJaxRS/resteasy/JacksonConfig.mustache

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,15 @@ import com.fasterxml.jackson.core.JsonGenerator;
55
import com.fasterxml.jackson.databind.ObjectMapper;
66
import com.fasterxml.jackson.databind.SerializerProvider;
77
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
8+
{{#java8}}
9+
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
10+
{{/java8}}
11+
{{#joda}}
812
import com.fasterxml.jackson.datatype.joda.JodaModule;
913
import org.joda.time.DateTime;
1014
import org.joda.time.LocalDate;
1115
import org.joda.time.format.ISODateTimeFormat;
16+
{{/joda}}
1217

1318
import javax.ws.rs.ext.ContextResolver;
1419
import javax.ws.rs.ext.Provider;
@@ -22,6 +27,10 @@ public class JacksonConfig implements ContextResolver<ObjectMapper> {
2227
2328
objectMapper = new ObjectMapper()
2429
.setDateFormat(new RFC3339DateFormat())
30+
{{#java8}}
31+
.registerModule(new JavaTimeModule());
32+
{{/java8}}
33+
{{#joda}}
2534
.registerModule(new JodaModule() {
2635
{
2736
addSerializer(DateTime.class, new StdSerializer<DateTime>(DateTime.class) {
@@ -39,9 +48,10 @@ public class JacksonConfig implements ContextResolver<ObjectMapper> {
3948

4049
}
4150
});
51+
{{/joda}}
4252
}
4353

4454
public ObjectMapper getContext(Class<?> arg0) {
4555
return objectMapper;
4656
}
47-
}
57+
}

0 commit comments

Comments
 (0)