Android 时间控件修改生日
private class TextView_persinal_birth_onClick implements View.OnClickListener {
@Override
public void onClick(View v) {
DatePickerDialog.OnDateSetListener dateSetListener=new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
calendar.set(Calendar.YEAR,year);
calendar.set(Calendar.MONTH,monthOfYear);
calendar.set(Calendar.DAY_OF_MONTH,dayOfMonth);
try {
Date date_input=simpleDateFormat.parse(simpleDateFormat.format(calendar.getTime()));
Date date_system=simpleDateFormat.parse(simpleDateFormat.format(Calendar.getInstance().getTime()));
long inputTime=date_input.getTime();
long systemTime=date_system.getTime();
if (inputTime<=systemTime){
birth=simpleDateFormat.format(calendar.getTime());
textView_persional_birth.setText(birth);
}
else
Toast.makeText(PersonalInformationActivity.this,"生日不能大于当前日期!",1).show();
} catch (ParseException e) {
e.printStackTrace();
}
}
};
new DatePickerDialog(PersonalInformationActivity.this,
dateSetListener,
calendar.get(Calendar.YEAR),
calendar.get(Calendar.MONTH),
calendar.get(Calendar.DAY_OF_MONTH)).show();
}
}
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。