There is an updateDate method for updateDate .
Here is what I use in one of my applications without using a dialog:
//set datePicker to position String date_saved = project_row.getString( project_row.getColumnIndex("project_startdate")); int day = Integer.parseInt(date_saved.substring(0,2)); int year = Integer.parseInt(date_saved.substring(5,9)); String month = date_saved.substring(2,5); int month_code = getMonthInt(month); project_startdate_data = (DatePicker) findViewById(R.id.project_startdate_data); project_startdate_data.updateDate(year, month_code, day);
where project_row is my cursor and the date is stored in the project_startdate column as 22MAY2012
and you need it:
private int getMonthInt(String month) { if (month.equalsIgnoreCase("JAN")) return 0; if (month.equalsIgnoreCase("FEB")) return 1; if (month.equalsIgnoreCase("MAR")) return 2; if (month.equalsIgnoreCase("APR")) return 3; if (month.equalsIgnoreCase("MAY")) return 4; if (month.equalsIgnoreCase("JUN")) return 5; if (month.equalsIgnoreCase("JUL")) return 6; if (month.equalsIgnoreCase("AUG")) return 7; if (month.equalsIgnoreCase("SEP")) return 8; if (month.equalsIgnoreCase("OCT")) return 9; if (month.equalsIgnoreCase("NOV")) return 10; if (month.equalsIgnoreCase("DEC")) return 11; //return -1 if month code not found return -1; }
Mirko Nov 28 '12 at 16:45 2012-11-28 16:45
source share