问题
Is there a simple way how to get week of year information from a Date object or from millis time in GWT on the client side?
回答1:
Something like this:
Date date = new Date();
Date yearStart = new Date(date.getYear(), 0, 0);
int week = (int) (date.getTime() - yearStart.getTime())/(7 * 24 * 60 * 60 * 1000);
Note that this will give you a week in a Date object, which has no time zone information. When you use it, you may have to adjust it using the time zone information.
回答2:
How to do it with GWT object not sure but because GWT code is converted to javascript at compile time, so you could make something like this:
http://javascript.about.com/library/blweekyear.htm
来源:https://stackoverflow.com/questions/23938938/how-to-get-week-of-year-figure-in-gwt