我有一个程序,它在很大程度上依赖于确定该年度的周数。我已经完成了腿部工作,并找出了所有会导致这种方法并解决的问题。我的作品完美多年,有53周等。我唯一的问题是,当我在2.2版本的仿真器上运行它时,它是完美的,就像这是第19周,它是正确的。当我在G1手机上运行它时,本周显示为20.我该如何解决这个问题?Android的周数错了电话,但没有模拟器
这里是我的星期代码:(我要离开这一个评论,但我的账号还没有评论权限)
/**
* Format the date into a number that is the year*100 plus the week i.e. 2008 and its week 11
* would show as 811
* @param - String of a date to create a week id, must be in format of 2011-01-31 (YYYY-MM-DD)
* @return returns next weeks id
*/
public static int getWeekId(String date){
// Set the first day of week to Monday and set the starting new year weeks
// as a full first week in the new year.
Calendar c = Calendar.getInstance();
c.setFirstDayOfWeek(Calendar.MONDAY);
c.setMinimalDaysInFirstWeek(7);
if (!date.equalsIgnoreCase("")) {
String[] token = date.split("-", 3);
int year = Integer.parseInt(token[0]);
int month = Integer.parseInt(token[1])-1; // months are 0-11 stupid..
int day = Integer.parseInt(token[2]);
c.set(year, month, day);
}
int yearWeek = ((c.get(Calendar.YEAR) - 2000)*100 + (c.get(Calendar.WEEK_OF_YEAR)));
Log.d("getWeekId()"," WEEK_OF_YEAR: " + c.get(Calendar.WEEK_OF_YEAR));
return yearWeek;
}
我做一些后期处理正确弄清楚年,年周实际上是1052第一周今年开始时间Jan 03和1月1日和2日是在2010年用了52周说,主问题是在2.2属下19个星期的今天和我的G1(1.6),其20这是怎么回事,以及如何解决星期? – JPM 2011-05-13 05:16:01