简体   繁体   English

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

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

I am Using GWT. 我正在使用GWT。

I need to retrieve the current date and and last week date. 我需要检索当前日期和上周日期。 and pass it to GWT server using RPC. 并使用RPC将其传递给GWT服务器。

How to retrieve the system date and last week date.?? 如何检索系统日期和上周日期。??

You will Get Date/Time in/with GWT. 您将获得GWT中的日期/时间。

  • get a unix time stamp since the epoch 从纪元开始获得unix时间戳
  • get year, month, today, date, hours, minutes seconds 获得年,月,今天,日期,小时,分钟秒

//Get the browsers date (!!!note: I can't get GMT time zone in eclipse debugger) //获取浏览器日期(!!!注意:我在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);

****** other wise Visit following link to get more information ******其他明智访问以下链接以获取更多信息

1) a GWTInfo 1) GWTInfo

2)one more a Stack 2)再一个堆栈

I hope it will help. 我希望它会有所帮助。

I make it using calculation by stander date util 我使用stander date util计算它

you can find the date as below 你可以在下面找到日期

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

Today will get current day, fromDay will get past 6 day 今天将获得当天,距离将过去6天

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

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