我正在阅读GWT教程,在输入这一行之后,我的IDE抱怨对DateTimeFormat.getMediumDateTimeFormat()的调用是不可取的:
(“最后更新:”+ DateTimeFormat.getMediumDateTimeFormat().format(new Date());
我该怎么换电话呢?
发布于 2011-01-21 16:11:25
根据这份文件,您需要使用getFormat(DateTimeFormat.PredefinedFormat.DATE_MEDIUM)
发布于 2013-02-16 16:25:44
我无法得到工作的最后答案。它给出了同样的结果,只是一个日期戳。
试试这个:
lastUpdatedLabel.setText("Last update: " +
DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_TIME_MEDIUM)
.format(new Date()));发布于 2012-09-06 13:53:39
我可以听听你的意见吗,奥利弗·韦勒?也许它对你来说太老了..。但我是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
https://stackoverflow.com/questions/4760933
复制相似问题