Note: The solution referenced by a couple of people here does not work for my problem...
I have a java.sql.Timestamp field that I want to format to a String in my getter. I'm using Lombok @Data at the beginning of the class. But when I override Lombok's getter with my own getter (to format the Timestamp), the field is always null. I don't see anything in the documentation to explain this behavior.
This block of code gives me the settlementDate as a Timestamp:
@Data
public class MyObject {
public Timestamp settlementDate;
}
This block of code gives me a NPE, because the settlementDate is null. Hmm, it just occurred to me... Could it be because the return type of the getter is different from the member type?
@Data
public class MyObject {
public Timestamp settlementDate;
String getSettlementDate() {
return new SimpleDateFormat("yyyy-MM-dd").format(tradeDate);
}
}