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)); }