Once I solved my problem like this -
String.format("%.6f", latitude);
The return value is a string. Therefore, you can use this if you need the result of a string.
If you need to double, you can convert using the method Double.parseDouble().
source
share