1. Are you ready for the Galaxy S20? Here is everything we know so far!

Datepicker problem

Discussion in 'Android Development' started by dimis, Sep 26, 2021.

  1. dimis

    dimis Lurker
    Thread Starter

    I have a problem setting a date() at the datepicker item at my activity ,I use the bellow code and the date does not apply at DatePicker, what is wrong ?
    Date date = myapp.getAdate();// the date instance
    Calendar cal = Calendar.getInstance();
    DatePicker picker=(DatePicker)findViewById(R.id.datePicker1);
    int year=cal.get(Calendar.YEAR);
    int day=cal.get(Calendar.DAY_OF_MONTH);
    int mnth=cal.get(Calendar.MONTH)-1;
    picker.init( year, mnth,day,null);
    [EDIT] I noticed that the problem is the date that I set -> cal.setTime(date);
    How I have to set the date, it has the format dd/MM/yyyy
    [EDIT No 2] I solve this problem ,it works ok for now.Thank you!

    #1 dimis, Sep 26, 2021
    Last edited: Sep 26, 2021

    1. Download the Forums for Android™ app!



Share This Page