java通过选择年月生成天下拉框

private void  changeDayComboBox(String dyear,String dmouth){
    SimpleDateFormat simpleDate = new SimpleDateFormat("yyyy/MM");
    Calendar rightNow = Calendar.getInstance();
    try{
        rightNow.setTime(simpleDate.parse(dyear+"/"+dmouth));
    }catch(ParseException e){
        e.printStackTrace();
    }
    int days = rightNow.getActualMaximum(Calendar.DAY_OF_MONTH);//根据年月 获取月份天数
     DefaultComboBoxModel list = new DefaultComboBoxModel();
    for(int i = 0; i < days; i++){
        list.addElement(i+1);
    }
    m_DayComboBox.setModel(list);
}


 
  

调用

changeDayComboBox("2015","7");


你可能感兴趣的:(java通过选择年月生成天下拉框)