我经历的GWT教程和进入这一行后,我的IDE抱怨 调用DateTimeFormat.getMediumDateTimeFormat()
被弃用:如何替换此弃用的方法调用?
lastUpdatedLabel.setText( “最后更新时间: ” + DateTimeFormat.getMediumDateTimeFormat( ).format(new Date()));
我该如何更换呼叫?
我经历的GWT教程和进入这一行后,我的IDE抱怨 调用DateTimeFormat.getMediumDateTimeFormat()
被弃用:如何替换此弃用的方法调用?
lastUpdatedLabel.setText( “最后更新时间: ” + DateTimeFormat.getMediumDateTimeFormat( ).format(new Date()));
我该如何更换呼叫?
据this documentation,你需要使用getFormat(DateTimeFormat.PredefinedFormat.DATE_MEDIUM)
能不能给我改正或者你的意见,奥利弗·维勒? 也许这对你来说太陈旧了......但我是JAVA和GWT的新手... 我想知道下面的代码是否是这个不赞成使用的方法的一个好的和有效的解决方案。
谷歌教程给这个: https://developers.google.com/web-toolkit/doc/latest/tutorial/codeclient#timestamp
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
我无法得到最后的答案工作。它只给出日期戳的结果。
试试这个:
lastUpdatedLabel.setText("Last update: " +
DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_TIME_MEDIUM)
.format(new Date()));
@Manu,你可以用
DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_TIME_MEDIUM).format(new Date())
这似乎是一个地道的GWT团队的答案取代
DateTimeFormat.getMediumDateTimeFormat().format(new Date())
因为我发现它在https://code.google.com/p/google-web-toolkit/issues/detail?id=8241#c3
这应该是一条评论。 – helpermethod 2014-08-06 06:11:41
Thx,工作。虽然我不得不使用`DATE_TIME_MEDIUM`。 – helpermethod 2011-01-21 16:14:27