comparing current date and time with got date and time .

Sep 18 2014 12:36 AM
date = formatter.parse(dateInString); 			
time = (Date) formatterTime.parse(timeInString);
Calendar current = Calendar.getInstance();
Calendar cal = Calendar.getInstance();
/* cal.set(DatePicker.g, pickerDate.getMonth(), pickerDate.getDayOfMonth(), pickerTime.getCurrentHour(),
* pickerTime.getCurrentMinute(), 00); */

cal.set(date.getYear(),date.getMonth(),date.getDay(),time.getHours(),time.getMinutes());//error i think so
if (cal.compareTo(current) <= 0)
{ // setAlarm(cal);
// The set Date/Time already passed
Toast.makeText(getApplicationContext(), "Invalid Date/Time", Toast.LENGTH_LONG).show();
} else {
setAlarm(cal);
db.addContact(new Contact_details(name1, mobile_number1, home_number1, company_name1, jobtitle1, emailid1, date, time));
}


if i set date and time greater also i am getting invalid date and time ?.can anyone say how to compare date and time

Answers (3)