//设置DateDialog为当前时间
Calendar calendar = Calendar.getInstance();
showDateDialog(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DATE));
private void showDateDialog(int pYear,int pMonth,int pData){
new DatePickerDialog(this, new OnDateSelectedListener(), pYear, pMonth, pData).show();
}
//在监听类中获取设置后的时间
class OnDateSelectedListener implements DatePickerDialog.OnDateSetListener {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
Date _Date = new Date(year - 1900, monthOfYear, dayOfMonth); //获取时间转换为Date对象
}
}
获取DatePickerDialog的时间
最新推荐文章于 2021-05-26 00:03:22 发布