GWT / Java Date api中的星期几

问题描述 投票:0回答:3

如何在客户端的Date中获得给定GWT的星期几?

我知道我可以使用DategetDay()对象获得它,但我不确定这是否是最好的方法。

还有其他选择吗?

使用Java Date api的弃用方法是否可接受且可靠?

java date gwt
3个回答
2
投票

尝试

DateTimeFormat format = DateTimeFormat.getFormat("c"); // try with "E" pattern also

String dayOfWeek = format.format(new Date());
System.out.println(dayOfWeek);

有关更多模式,请查看DateTimeFormat

产量

0 for sunday

2
投票

在更好的选项可用之前,在GWT代码中使用getDay()没有任何害处。它已被弃用,但没有计划很快删除此方法。


1
投票

使用JsDate.getDay()它非常好用。

© www.soinside.com 2019 - 2024. All rights reserved.