set DatePickerDialog one day before
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.
精彩评论