Calendar.MONTH gives wrong value

后端 未结 6 1960
醉酒成梦
醉酒成梦 2020-12-19 01:14

I\'m trying to get the actual month from the Calendar using the following:

Calendar c = Calendar.getInstance();          
String time = String.v         


        
6条回答
  •  春和景丽
    2020-12-19 01:43

    use this

        public void DateDialog(){
    
        DatePickerDialog.OnDateSetListener listener=new DatePickerDialog.OnDateSetListener() {
            @Override
            public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth)
            {
                int Month;
                Month=monthOfYear+1;
                fromDate.setText(year + "-" + Month + "-" + dayOfMonth);
            }};
        DatePickerDialog dpDialog=new DatePickerDialog(getActivity(), listener, year, month, day);
        dpDialog.getDatePicker().setMinDate(mcalendar.getTimeInMillis());
        dpDialog.show();
    }
    

提交回复
热议问题