如何在Smartgwt应用程序中获取当前系统日期(仅限javascript)。我需要在2010年10月25日打印日期。目前我正在使用
以下代码:
String currentDate ;
java.util.Date date = new Date();
String tempDate = date.toString();
String[] currDate = tempDate.split(" ");
currentDate = currDate[2] + " " + currDate[1] + " "
+ currDate[currDate.length - 1];
但我想如果系统/服务器的语言环境发生变化,这将无效。你能告诉我任何获得约会的方法吗?
答案 0 :(得分:3)
您可以使用JSNI调用Javascript方法:
public native String getLocaleDateString() /*-{
return new Date().toLocaleDateString();
}-*/;
GWT 2.1将引入新的JsDate
类:
JsDate.create().toLocaleDateString();
答案 1 :(得分:3)
在SmartGWT中,有一个DateUtil类可以完全满足您的需求;见http://www.smartclient.com/smartgwt/javadoc/com/smartgwt/client/util/DateUtil.html
您可以在SmartGWT论坛上找到一个用法示例:http://forums.smartclient.com/showthread.php?t=13920&highlight=DateUtil
希望这有帮助。
答案 2 :(得分:0)
在smart gwt中你可以使用java类。
此日期将在客户端日期。
这将有效.....