简体   繁体   English

我的2个Android手机中的Calendar.WEEK_OF_YEAR不同

[英]Calendar.WEEK_OF_YEAR is Different in My 2 Android Phone

I have this code 我有这个代码

Calendar c = Calendar.getInstance();
c.set(Calendar.YEAR, year);
c.set(Calendar.MONTH, month - 1);
c.set(Calendar.DAY_OF_MONTH, 1);

When you get the c.get(Calendar.WEEK_OF_YEAR) it produce different week number 当您得到c.get(Calendar.WEEK_OF_YEAR)它会产生不同的星期数

example c.set(2016, Calendar.JANUARY, 1); 例如c.set(2016, Calendar.JANUARY, 1);

one android phone produce c.get(Calendar.WEEK_OF_YEAR) = 1 and the other one is c.get(Calendar.WEEK_OF_YEAR) = 53 一个Android手机产生c.get(Calendar.WEEK_OF_YEAR) = 1,而另一个是c.get(Calendar.WEEK_OF_YEAR) = 53

There are several ways to count the weeks-of-year. 有几种方法可以计算一年中的几周。 This will probably help you: https://stackoverflow.com/a/4608695 这可能会帮助您: https : //stackoverflow.com/a/4608695

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

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