开发者

How to compare current date with date from the picker

开发者 https://www.devze.com 2023-04-12 22:04 出处:网络
I have a datetimepicker which i used to get the date and set it as label in my screen. Now i want to check if the entered date is valid or not. i.e., the entered date should be bigger than or equal to

I have a datetimepicker which i used to get the date and set it as label in my screen. Now i want to check if the entered date is valid or not. i.e., the entered date should be bigger than or equal to the current date. Please tell with a code. Thank you

StringBuffer dateStrDate = new StringBuffer();

Calendar Cal = datePickerDate.开发者_如何转开发getDateTime();

SimpleDateFormat dateFormat = new SimpleDateFormat("yy:mm:dd"); dateFormat.format(Cal, dateStrDate, null);

time.setText(dateStrDate.toString());


DateTimePicker datePicker = DateTimePicker.createInstance(Calendar.getInstance(), "yyyy-MM-dd", null);
if(datePicker.doModal()) {
    Calendar cal = datePicker.getDateTime();
    int month=cal.get(cal.MONTH);
    int year=cal.get(cal.YEAR); 
    int date1=cal.get(cal.DATE);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号