简体   繁体   中英

How to get a last Week date in GWT

I am Using GWT.

I need to retrieve the current date and and last week date. and pass it to GWT server using RPC.

How to retrieve the system date and last week date.??

You will Get Date/Time in/with GWT.

  • get a unix time stamp since the epoch
  • get year, month, today, date, hours, minutes seconds

//Get the browsers date (!!!note: I can't get GMT time zone in eclipse debugger)

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

2)one more a Stack

I hope it will help.

I make it using calculation by 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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