i am using JsonDeserializer to format my Date as below:
public class CustomDateMappingDeserialize extends JsonDeserializer<Date>{
@Override
public Date deserialize(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext) throws IOException, JsonProcessingException {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
String date = paramJsonParser.getText();
try {
Date formattedDate= format.parse(date);
return formattedDate;
} catch (ParseException e) {
throw new RuntimeException(e);
}
}
}
but the problem is i have to define the Format fixed here and i have many different date formats.
Can we do something like this:
@JsonDeserialize(using = CustomDateMappingDeserialize.class, format ="yyy-dd-mm")
public void setDate(Date date) {
this.date = date;
}
Instead of defining it in Custom class ?
Any help/pointers would be highly appreciated.