java獲取當前月的天數



import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;

public class d {
	public static void main(String[] args) {
		Calendar   cal   =   new   GregorianCalendar();    
	    SimpleDateFormat oSdf = new SimpleDateFormat ("yyyy-MM");    
	    try {    
	        cal.setTime(oSdf.parse("2012-2"));    
	    } catch (ParseException e) {    
	        e.printStackTrace();    
	    }    
	    
	    int num2 = cal.getActualMaximum(Calendar.DAY_OF_MONTH);    
	    
	    System.out.println(num2);
	}
}

 

發佈了75 篇原創文章 · 獲贊 2 · 訪問量 3229
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章