我正在学习GWT教程,在输入以下代码后,我的IDE报错:调用DateTimeFormat.getMediumDateTimeFormat()
已被废弃:
lastUpdatedLabel.setText("最后更新时间: " + DateTimeFormat.getMediumDateTimeFormat().format(new Date()));
我该如何替换该调用?
我正在学习GWT教程,在输入以下代码后,我的IDE报错:调用DateTimeFormat.getMediumDateTimeFormat()
已被废弃:
lastUpdatedLabel.setText("最后更新时间: " + DateTimeFormat.getMediumDateTimeFormat().format(new Date()));
我该如何替换该调用?
我无法让上一个答案起作用。它只会返回一个日期戳。
试试这个:
lastUpdatedLabel.setText("Last update: " +
DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_TIME_MEDIUM)
.format(new Date()));
private void updateTable(StockPrice[] prices) {
for (int i = 0; i < prices.length; i++) {
updateTable(prices[i]);
}
// Display timestamp showing last refresh.
lastUpdatedLabel.setText("Last update : " + DateTimeFormat.getMediumDateTimeFormat().format(new Date()));
}
我把这个放在这里代替
private void updateTable(StockPrice[] prices) {
for (int i = 0; i < prices.length; i++) {
updateTable(prices[i]);
}
// Display timestamp showing last refresh.
DateTimeFormat format = DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_TIME_MEDIUM);
lastUpdatedLabel.setText("Last update : " + format.format(new Date()));
}
不知道为什么谷歌没有更新这个教程。
在这里确认一下:https://code.google.com/p/google-web-toolkit/issues/detail?id=8241#c3
感谢 @qbektrix
@Manu,你可以替换
DateTimeFormat.getMediumDateTimeFormat().format(new Date())
使用
DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_TIME_MEDIUM).format(new Date())
这似乎是一个真正的GWT团队答案,因为我在https://code.google.com/p/google-web-toolkit/issues/detail?id=8241#c3上找到了它。