Time Distance in hours and minutes
import java.text.SimpleDateFormat;
import java.util.Date;
public class Main {
static SimpleDateFormat dateFormater = new SimpleDateFormat("MM/dd/yyyy");
public static String getTimeDistance(Date from){
long minDist = (System.currentTimeMillis() - from.getTime())/60000;
if(minDist <= 0){
return (System.currentTimeMillis() - from.getTime())/1000 + " seconds";
}
else if(minDist >= 60){
return minDist/60 + " hours";
}
else{
return minDist + " minutes";
}
}
}