views:

94

answers:

1

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

DatePickerDialog.OnDateSetListener dini=new DatePickerDialog.OnDateSetListener() {
    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            
    }
};
+2  A: 

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

Jim Blackler
I think thats not so easy, I add -1 day to my Calendar.DAY_OF_MONTH but my Calendar.MONTH don't work show always the same month, I have march 1 minus 1 day, my result is DAY_OF_MONTH 28 but How could change my MONTH to feb! to have feb 28
As far I know they will get automatically changed, the overlap will be done for you.
Pentium10