如何获得GWT中的每周数字 [英] How to get week of year figure in GWT

查看:103
本文介绍了如何获得GWT中的每周数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种简单的方法,可以从 Date 对象或从 GWT 在客户端?

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?

推荐答案



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);

请注意,这会给你一个Date对象的一个​​星期,它没有时区信息。当您使用它时,您可能需要使用时区信息进行调整。

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.

这篇关于如何获得GWT中的每周数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆