Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
hi all, i don't know..whether this is the right forum tp post this doubt.. First of all my doubt is,how to find the difference between 2 time values in java. i have 2 values time1= "9.20" time2="18.00" what i want is the difference 8.40.how to get it? also the second doubt how to round a fraction to 2 decimal points... 8.6667899 to 8.67. pls help thanx in advance
------------------------------------------------------------- the second doubt how to round a fraction to 2 decimal points... 8.6667899 to 8.67. -------------------------------------------------------------
U can use NumberFormat Class. check the API for the method, i think its setMaximumFractionDigit(2). check the api for the method explanation.
---------------------------------------------------- the difference between 2 time values in java ----------------------------------------------------
U can convert the time to milliseconds, find the difference as its a integer and then convert back to hours.
public static double roundDoubleValue(double val2Round) { /* * Method to round off a recurring double value to a two decimal precision. * */ BigDecimal bd = new BigDecimal(val2Round); bd = bd.setScale(2, BigDecimal.ROUND_HALF_UP); // now to remove zero after decimal return bd.doubleValue(); } // end of method roundDoubleValue
brevity is the soul of wit - shakepeare. Tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth