嘿,我有来自 zkoss 的 datebox,我想将它与 java 8 localdate 和 localdatetime 一起使用。我试图在我的 datebox 类中扩展 datebox,但我无法让它工作,你有任何经验吗?我到处搜索,但我没有找到任何东西。谢谢
private LocalDate value;
private DateTimeFormatter format = DateTimeFormatter.ofPattern("dd.MM.yyyy ");
public Datebox() {
super();
}
public Datebox(LocalDate dateTime) {
this.value = dateTime;
}
protected String getDefaultFormat() {
return format.toString();
}
@Override
protected Object coerceFromString(String value) throws WrongValueException {
return (value == null) ? null : format.parse(value);
}
@Override
protected String coerceToString(Object value) {
return (value == null) ? null : format.format((TemporalAccessor) value);
}
@Override
protected Object unmarshall(Object value) {
if (value == null) return value;
if (!(value instanceof LocalDate)) {
throw new WrongValueException(this, MZul.NUMBER_REQUIRED, value);
}
return value;
}
@Override
protected Object marshall(Object value) {
if (value == null) return value;
return value;
}
public LocalDate getValue() {
return value;
}
public void setValue(LocalDate value) {
this.value = value;
}