我的 GWT 项目有问题:我只想计算两个 DatePicker Widget 的两个日期(以天为单位)之间的差异。
这是我的代码,我主要从这里获取:http: //www.gwtproject.org/javadoc/latest/com/google/gwt/user/datepicker/client/DatePicker.html
// Create a date picker "FROM: "
final DatePicker datePicker1 = new DatePicker();
datePicker1.addValueChangeHandler(new ValueChangeHandler<Date>() {
public void onValueChange(ValueChangeEvent<Date> event) {
Date date1 = datePicker1.getValue();
}
});
// Set the default value
datePicker1.setValue(new Date(), true);
// Create a date picker "TO: "
final DatePicker datePicker2 = new DatePicker();
datePicker2.addValueChangeHandler(new ValueChangeHandler<Date>() {
public void onValueChange(ValueChangeEvent<Date> event) {
Date date2 = datePicker2.getValue();
}
});
// Set the default value
datePicker2.setValue(new Date(), true);
// =================DEBUG===================
Button send = new Button("send", new ClickHandler(){
public void onClick(ClickEvent event) {
//calculate difference between date1 and date2
days = (int) CalendarUtil.getDaysBetween(date1, date2);
Window.alert("Differece: " + days);
}
});
但是虽然我在 Eclipse 中没有错误,但当我运行 Web 应用程序时,我遇到了这个错误:
[ERROR] [progetto] Uncaught exception escaped
com.google.gwt.event.shared.UmbrellaException: Exception caught: null
[...]
如有必要,我可以写更多的错误细节,但它很长......
你能告诉我如何修复这个错误或如何用其他方法计算它吗?
先感谢您。