I want to compare two time based so i just convert time to date.
i have parse time like this:
SimpleDateFormat h_mm_a = new SimpleDateFormat("h:mm a");
Date d1 = h_mm_a.parse(txtTimeFrom.getText().toString());
Date d2 = h_mm_a.parse(txtTimeTo.getText().toString());
if(d1.compareTo(d2)<0){
....................
}
else{
Toast.makeText(ExecutiveRouteTracking.this,"Invalid Time",Toast.LENGTH_SHORT).show();
}
It will throw exception like
java.text.ParseException: Unparseable date: “9:30 AM” (at offset 5)
Can any one help me to solve problem to compare two time?