How to get week of year figure in GWT

江枫思渺然 提交于 2019-12-23 17:14:41

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!