Uwaga: Poprawione kod jak poniżej które zapewniają Chirag Raval, ponieważ w kodzie, który Chirag str rovided miał pewne problemy, gdy próbujemy znaleźć czas od 22:00 do 07:00.
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm");
Date startDate = simpleDateFormat.parse("22:00");
Date endDate = simpleDateFormat.parse("07:00");
long difference = endDate.getTime() - startDate.getTime();
if(difference<0)
{
Date dateMax = simpleDateFormat.parse("24:00");
Date dateMin = simpleDateFormat.parse("00:00");
difference=(dateMax.getTime() -startDate.getTime())+(endDate.getTime()-dateMin.getTime());
}
int days = (int) (difference/(1000*60*60*24));
int hours = (int) ((difference - (1000*60*60*24*days))/(1000*60*60));
int min = (int) (difference - (1000*60*60*24*days) - (1000*60*60*hours))/(1000*60);
Log.i("log_tag","Hours: "+hours+", Mins: "+min);
Wynik będzie: Godziny: 9 min: 0
Klasa czas jest przydatna dla Android: http://stackoverflow.com/a/12739537/693752 – Snicolas