1 21 package org.lobobrowser.util; 22 23 public class Timing { 24 public static double round1(double value) { 25 return Math.round(value * 10.0) / 10.0; 26 } 27 28 public static String getElapsedText(long elapsedMillis) { 29 if(elapsedMillis < 60000) { 30 double unit = round1(elapsedMillis / 1000.0); 31 return unit + (unit == 1 ? " second" : " seconds"); 32 } 33 else if(elapsedMillis < 60000 * 60) { 34 double unit = round1(elapsedMillis / 60000.0); 35 return unit + (unit == 1 ? " minute" : " minutes"); 36 } 37 else if(elapsedMillis < 60000 * 60 * 24) { 38 double unit = round1(elapsedMillis / (60000.0 * 60)); 39 return unit + (unit == 1 ? " hour" : " hours"); 40 } 41 else { 42 double unit = round1(elapsedMillis / (60000.0 * 60 * 24)); 43 return unit + (unit == 1 ? " day" : " days"); 44 } 45 } 46 } 47 | Popular Tags |