Simply I have the following class to get my JSON body that received from remote response to deserialize to CreditCardDTO
the date recieved inside exp_date
like "0820" for 8/2010, and "0240" for 2/2040:
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Date;
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonPropertyOrder(alphabetic = true)
public class CreditCardDTO {
private String brand;
private Date expirationDate;
@JsonProperty("brand")
public String getBrand() {
return brand;
}
@JsonProperty("credit_card_type")
public CreditCardDTO setBrand(String brand) {
this.brand = brand;
return this;
}
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ")
@JsonProperty("expirationDate")
public Date getExpirationDate() {
return expirationDate;
}
@JsonFormat(pattern = "MMyy")
@JsonProperty("exp_date")
public CreditCardDTO setExpirationDate(Date expirationDate) {
System.out.println(expirationDate);
this.expirationDate = expirationDate;
return this;
}
}
The problem that if it is before Year 2038 everything is OK, but once the data is after that critical date, it still happens, the data is back to 1941, I searched about the problem and found that it should not be happen in Java 8 : Why should a Java programmer care about year 2038 bug? , so I'm wondering what the issue here!
Jackson version 2.8.0, Java 8 for sure.