public class Test {
public static void main(String[] args) throws Exception{
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar cl = Calendar.getInstance();
cl.setTime(sdf.parse("2012-12-31"));
int week = cl.get(Calendar.WEEK_OF_YEAR);
int year = cl.get(Calendar.YEAR);
System.out.println(year+"年"+week+"周");
}
}
结果:
2012年1周
计算跨年的周数 有什么好的算法?
|
|