Created
July 17, 2018 13:16
-
-
Save tomaszalusky/bcf03674bf58f7efdd2441fd3fa73f08 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.fasterxml.jackson.core.JsonProcessingException; | |
import com.fasterxml.jackson.databind.ObjectMapper; | |
import com.fasterxml.jackson.databind.SerializationFeature; | |
import com.fasterxml.jackson.datatype.joda.JodaModule; | |
import org.joda.time.LocalDate; | |
public class Main { | |
static class Foo { | |
String name; | |
LocalDate date; | |
public String getName() { | |
return name; | |
} | |
public void setName(String name) { | |
this.name = name; | |
} | |
public LocalDate getDate() { | |
return date; | |
} | |
public void setDate(LocalDate date) { | |
this.date = date; | |
} | |
} | |
public static void main(String[] args) throws JsonProcessingException { | |
Foo foo = new Foo(); | |
foo.setName("x"); | |
foo.setDate(LocalDate.now()); | |
ObjectMapper objectMapper = new ObjectMapper(); | |
objectMapper.registerModule(new JodaModule()); | |
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); | |
System.out.println(objectMapper.writeValueAsString(foo)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment