I calculate the difference between the two points, and I can get the difference in hours and blur with the help of separate equations, is there any one equation from which I can get hours and minutes in one pass. I use like:
here diff is the difference between two time values
long diffHours1 = diff / (60 * 60 * 1000); long min=diff/(60*1000);
I'm not sure if this is useful here, but Joda Time seems to have a slightly more detailed solution using Period , like
Period p = new Period(startDate, endDate) int minutes = p.getMinutes(); //returns the left over minutes part int seconds = p.getSeconds(); //returns the seconds part
I'm not sure that for this particular case you need something else than what you have, I agree with
is there any one equation from which i can get hours and minutes in one go
, . Java ; , ( , ..). , , .
, , , :
long diffMinutes = diff / (60*1000); long diffHours = diffMinutes / 60;
, :
String oneGo = (diff / (60 * 60 * 1000)) + " " + (diff / (60 * 1000));
: -)
, ( ), , .
diff = //time difference in milliseconds long diffInMinutes = diff / (60 * 1000); //get the number of hours, e.g. 140 / 60 = 2 long hours = diffInMinutes / 60; //get the left over minutes, e.g. 140 % 60 = 20 long minutes = diffInMinutes % 60;
, , , , Joda Time.