sebastianlee sebastianlee - 1 year ago 185
JSON Question

Jackson Date Format from HashMap

I have a problem with jackson outputting my date in the below format.


However, I want it to be something more readable. I have seen solutions using the jsonDateSerializer and Deserializer class and has some success in using it for POJO related implementation.

Jackson date deserialization

The problem I am facing right now would be the mapping of sql objects to a hashmap instead of a POJO. I am unclear where I could specify the object mapping part for hashmap

public @ResponseBody ArrayList<HashMap<String,Object>> sqlObjectRetrieval(){
ArrayList<HashMap<String,Object>> retrievedObjects =

I am using Spring3 and jackson for this implementation

Thanks in advance

Answer Source

Try to add

    <mvc:message-converters register-defaults="true">
        <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
            <property name="objectMapper">
                <bean class="com.fasterxml.jackson.databind.ObjectMapper">
                    <property name="dateFormat">
                        <bean class="java.text.SimpleDateFormat">
                            <constructor-arg value="yyyy-MM-dd HH:mm:ss"/>

in your spring-mvc.xml

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download