Hi how i can to get a decimal with place?, for example 9.924kms by 9.9kms
My code is
td = String.valueOf(totalDistance / 1000.0);
Hi how i can to get a decimal with place?, for example 9.924kms by 9.9kms
My code is
td = String.valueOf(totalDistance / 1000.0);
 
    
    Use DecimalFormat. You can also set RoundingMode to get the ceiling for last digit . Below is an example .
 double x=2.7883;
 DecimalFormat df = new DecimalFormat("#.0");
 System.out.println(df.format(x));
Output:- 2.8
For setting mode you can use .
 df.setRoundingMode(RoundingMode.FLOOR);
