繁体   English   中英

如何获得GWT的最后一周日期

[英]How to get a last Week date in GWT

我正在使用GWT。

我需要检索当前日期和上周日期。 并使用RPC将其传递给GWT服务器。

如何检索系统日期和上周日期。??

您将获得GWT中的日期/时间。

  • 从纪元开始获得unix时间戳
  • 获得年,月,今天,日期,小时,分钟秒

//获取浏览器日期(!!!注意:我在eclipse调试器中无法获得GMT时区)

Date date = new Date();

int Month = date.getMonth();

int Day = date.getDate();

int Year = date.getYear();

int Hour = date.getHours();

int min = date.getMinutes();

int sec = date.getSeconds();

int tz = date.getTimezoneOffset();

int UnixTimeStamp = (int) (date.getTime() * .001);//get unix time stamp example (seconds)

Long lTimeStamp = date.getTime(); //time in milleseconds since the epoch

int iTimeStamp = (int) (lTimeStamp * .001); //(Cast) to Int from Long, Seconds since epoch

String sTimeStamp = Integer.toString(iTimeStamp); //seconds to string

//get the gmt date - will show tz offset in string in browser, not eclipse debug window

String TheDate = date.toString();

//render date to root panel in gwt

Label label = new Label(TheDate);

RootPanel.get().add(label);

******其他明智访问以下链接以获取更多信息

1) GWTInfo

2)再一个堆栈

我希望它会有所帮助。

我使用stander date util计算它

你可以在下面找到日期

Date fromday = new Date(System.currentTimeMillis() - 6000L * 60L * 60L * 24L);
Date today = new Date(System.currentTimeMillis());

今天将获得当天,距离将过去6天

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM