开发者

How to compare current date with date from the picker

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜