您的位置:首页 > 编程语言 > Java开发

java取的3月第二个周日

2013-01-23 15:29 169 查看
Calendar cal2 = Calendar.getInstance();

/*设置时间为3月第二个礼拜天*/

cal2.set(Calendar.MONTH, 2);

cal2.set(Calendar.DAY_OF_MONTH, 1);

cal2.set(Calendar.DAY_OF_MONTH, getSecondSunDayDate(cal2.get(Calendar.DAY_OF_WEEK)));

public static int getSecondSunDayDate(int firstDayOfMonthByWeek){

switch (firstDayOfMonthByWeek){

case 1:

return 8;

case 2:

return 14;

case 3:

return 13;

case 4:

return 12;

case 5:

return 11;

case 6:

return 10;

case 7:

return 9;

}

return -1;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: