I am not getting current date in my datePickerDialog. Always x.xx.1900 :/
Here is my code:
Calendar c = Calendar.getInstance();
c.setTimeInMillis(System.currentTimeMillis());
int y = c.get(Calendar.YEAR);
int m = c.get(Calendar.MONTH);
int d = c.get(Calendar.DAY_OF_MONTH + Calendar.DAY_OF_WEEK);
return new DatePickerDialog(getActivity(),this,d,m,y);
and:
DialogFragment datePicker = new DateFragment();
datePicker.show(getSupportFragmentManager(), "datePicker");
the constructor of DatePickerDialog
is
public DatePickerDialog (Context context, DatePickerDialog.OnDateSetListener callBack, int year, int monthOfYear, int dayOfMonth)
You should use this :
Calendar c = Calendar.getInstance();
c.setTimeInMillis(System.currentTimeMillis());
int y = c.get(Calendar.YEAR);
int m = c.get(Calendar.MONTH);
int d = c.get(Calendar.DAY_OF_MONTH);
return new DatePickerDialog(getActivity(),this,y,m,d);
Use This to get the The Latest Date
public String getDisplayDate(){
return (dt.getDate()+"/"+(dt.getMonth()+1)+"/"+(dt.getYear()+1900));
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.