Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tomaszalusky/bcf03674bf58f7efdd2441fd3fa73f08 to your computer and use it in GitHub Desktop.
Save tomaszalusky/bcf03674bf58f7efdd2441fd3fa73f08 to your computer and use it in GitHub Desktop.
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