我会从一个日期开始得到一年半月的数字。例如,我有 13-Mar-2012,结果是 6。
我已尝试使用 Calendar 类,但无法正常工作:
Calendar cal = (GregorianCalendar) Calendar.getInstance();
cal.set(Calendar.DAY_OF_MONTH,13);
cal.set(Calendar.MONTH, 2);
cal.set(Calendar.YEAR, 2012);
int weekNum = cal.get(Calendar.WEEK_OF_YEAR);
System.out.println("Weeknum:" + ((weekNum/2)));
谁能帮我?