开发者

set DatePickerDialog one day before

开发者 https://www.devze.com 2022-12-26 17:06 出处:网络
hi I have a datepickerdialog but i´d like to change always one day before DatePickerDialog.OnDateSetListener dini=new DatePickerDialog.OnDateSe开发者_开发百科tListener() {

hi I have a datepickerdialog but i´d like to change always one day before

DatePickerDialog.OnDateSetListener dini=new DatePickerDialog.OnDateSe开发者_开发百科tListener() {
    public void onDateSet(DatePicker view, int year, int monthOfYear,
            int dayOfMonth) {
        myInitialDate.set(Calendar.YEAR, year);
        myInitialDate.set(Calendar.MONTH, monthOfYear);
        myInitialDate.set(Calendar.DAY_OF_MONTH, dayOfMonth);
        monthOfYear +=1; //fix month            
    }
};


Build a Calendar object, do the date arithmetic there and extract the new year/moy/dom using its getters.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号