[英]ZK datebox with java.time
嘿,我有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;
}
关于DateBox的ZK组件引用建议使用setFormat()方法来应用首选日期格式。
假设您的代码来自扩展ZK Datebox的类,那么您可以实现一个简单的formatter方法:
protected void setDateFormat(String dateFormat) {
return setFormat(dateFormat); // <- ZK method of the DateBox
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.