1 import java.util.Calendar;
 2 /**
 3  * 功能概述:计算指定年月的天数和周数<br>
 4  * 创建时间:2010-5-17 下午05:25:58<br>
 5  * 
 6  * @author <a href="mailto:hemingwang0902@126.com" mce_href="mailto:hemingwang0902@126.com">何明旺</a>
 7  */
 8 public class Test{
 9     public static void main(String[] args) {
10         Calendar c = Calendar.getInstance();
11         c.set(Calendar.YEAR, 2010); // 2010年
12         c.set(Calendar.MONTH, 5); // 6 月
13         System.out.println("------------" + c.get(Calendar.YEAR) + "年" + (c.get(Calendar.MONTH) + 1) + "月的天数和周数-------------");
14         System.out.println("天数:" + c.getActualMaximum(Calendar.DAY_OF_MONTH));
15         System.out.println("周数:" + c.getActualMaximum(Calendar.WEEK_OF_MONTH));
16     }
17 }