i want to compare two time (hour and minute) in textView. I try to convert there into millisecond, but it looks does'n work. Or maybe you have other way to covert . .
String startTime = (String) tvDisplayTime.getText();
String endTime = (String) tvDisplayTime.getText();
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
try {
Date StartDate = sdf.parse(startTime);
long timeInMillisecondsStart = StartDate.getTime();
Date EndDate = sdf.parse(endTime);
long timeInMillisecondsEnd = Enddate.getTime();
long result = timeInMillisecondsEnd-timeInMillisecondsStart;
if (result > 0){
Toast.makeText(MainActivity.this, " Work ", Toast.LENGTH_LONG).show();
}else{
Toast.makeText(MainActivity.this, " Failed ", Toast.LENGTH_LONG).show();
}
} catch (ParseException e) {
e.printStackTrace();
}