Search code examples
javaandroidandroid-datepicker

Setting DatePicker not working?


I am trying to set my DatePicker to the current date in the OnCreate method of my activity:

    DatePicker dp = (DatePicker) findViewById(R.id.datePicker);
    Calendar c = Calendar.getInstance();
    int day = c.get(Calendar.DAY_OF_MONTH);
    int month = c.get(Calendar.MONTH);
    int year = c.get(Calendar.YEAR);
    dp.updateDate(year, month, day);

However this does not seem to change it?


Solution

  • Just to let you all know, that code actually works fine my problem was that the date of my device was wrong! Sorry about that :)