1

I am trying to send json to server and i get the following exception:

Resolving exception from handler [public void com.hexgen.api.facade.HexgenWebAPI.createInvestAdjust(com.hexgen.ro.request.InvestAdjustRO,boolean)]: org.springframework.http.converter.HttpMessageNotReadableException: Could not read JSON: Invalid format: "01/09/2012" is malformed at "/09/2012" (through reference chain: com.hexgen.ro.request.InvestAdjustRO["transDate"]); nested exception is org.codehaus.jackson.map.JsonMappingException: Invalid format: "01/09/2012" is malformed at "/09/2012" (through reference chain: com.hexgen.ro.request.InvestAdjustRO["transDate"])

and this is what is my JSON:

adjustmentType: "UAMORT"
custodian: "DEUTSCHE"
debitCredit: "CREDIT"
investCategory: "FVTPL"
isUploaded: false
portfolio: "HEXGENFUND"
portfolioCcy: "INR"
recRemarks: "Test"
transDate: "01/09/2012"
transRef: "OP120010020000017"

this is what is my java code with getter and setter :

private String transId;
    private String portfolio;
    private String portfolioCcy;
    private String transRef;
    private String adjustmentType;
    private LocalDate transDate;
    private String debitCredit;
    private String investCategory;
    private String custodian;
    private String recRemarks;
    private RecStatus recStatus;
    private Boolean isUploaded=true;

what is the issure here and why do i get

nested exception is org.codehaus.jackson.map.JsonMappingException: Invalid format: "01/09/2012" is malformed at "/09/2012" (through reference chain: com.hexgen.ro.request.InvestAdjustRO["transDate"])

thanks

Amin Abu-Taleb
  • 4,423
  • 6
  • 33
  • 50
Java Questions
  • 7,813
  • 41
  • 118
  • 176

1 Answers1

1

Try to use this annotation to specify your date format:

private String transId;
private String portfolio;
private String portfolioCcy;
private String transRef;
private String adjustmentType;

@DateTimeFormat(pattern = "dd/MM/yyyy")
private LocalDate transDate;
private String debitCredit;
private String investCategory;
private String custodian;
private String recRemarks;
private RecStatus recStatus;
private Boolean isUploaded=true;
Amin Abu-Taleb
  • 4,423
  • 6
  • 33
  • 50