Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.nkapps.billing.services; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonSerializer; import com.fasterxml.jackson.databind.SerializerProvider; import java.io.IOException; import org.joda.time.LocalDateTime; import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormatter; /** * * @author nuraddin */ public class CustomJodaTimeSerializer extends JsonSerializer<LocalDateTime> { @Override public void serialize(LocalDateTime t, JsonGenerator gen, SerializerProvider arg2) throws IOException, JsonProcessingException { DateTimeFormatter dtf = DateTimeFormat.forPattern("dd.MM.yyyy HH:mm:ss"); String formattedDate = dtf.print(t); gen.writeString(formattedDate); } }