I have a timestamp property called "end date". I want when the user
views/enters it, to work only with the date part, but to be stored in the DB as
a timestamp. Here is how I tried to implement this in the entity class:
@javax.jdo.annotations.Persistent(defaultFetchGroup="true")
private DateTime endDate;
@javax.jdo.annotations.Column(name = "end_date", allowsNull = "true")
@Property(hidden = Where.ALL_TABLES)
public DateTime getEndDate() {
return endDate;
}
public void setEndDate(DateTime endDate) {
this.endDate = endDate;
}
@MemberOrder(sequence = "5")
@Property(notPersisted = true)
@PropertyLayout(named = "End date")
public LocalDate getLocalEndDate() {
return convertEndDate(getEndDate()); //converts it to Toronto time zone and
cuts the time part
}
public void setLocalEndDate(LocalDate localEndDate) {
setEndDate(convertEndDate(localEndDate)); //converts it to 23:59:59 in
Toronto time zone
}
This way the setting of the date does not works. I debugged it and found that
right after setting the value, the framework sets it back to null.
I have one more property - "start date" which is implemented the same way and
it works.
Initially I have implemented this without the getter and the setter for the
field itself (no getEndDate and setEndDate). And working directly with the
field, and it was working, but when I enabled auditing, the auditing for this
property didn't work.
Please advise what will be the right way to implement it.
Thanks in advance!