我正在尝试从给定日期获取当前周数。即如果我输入日期为01/03/2013,那么我应该得到周数为9 ..
请帮助我找到解决方案..
谢谢..
阿布舍克巴克..
答案 0 :(得分:14)
您可以为该日期创建一个日历对象,并使用calendar.get(日历.WEEK_OF_YEAR)获取一周。 API在此处描述:http://developer.android.com/reference/java/util/Calendar.html#WEEK_OF_YEAR
答案 1 :(得分:9)
Calendar calender = Calendar.getInstance();
Log.d("Current Week:" + calender.get(Calendar.WEEK_OF_YEAR));
答案 2 :(得分:4)
Calendar sDateCalendar = new GregorianCalendar(2013,03,01);
Calendar.getInstance().get(Calendar.WEEK_OF_YEAR);
答案 3 :(得分:0)
01/03/2013被收录为113,2,1
Date d = new Date(113, 2, 1);
Calendar c = Calendar.getInstance();
c.setTime(d);
int weekOfYear = c.get(Calendar.WEEK_OF_YEAR);
答案 4 :(得分:0)
Calendar calender = Calendar.getInstance(); Log.d("当前周:" + calender.get(Calendar.WEEK_OF_YEAR));