Reputation: 71
I developed a GPS application , and i get the values like :
78.38582246667-17.4532826666
but i need like:
78.385 - 17.453
i am using DecimalFormating also. But i am not get the Logitude and Latitude upto 3 decimal points.
here is my sample code:
if (location != null) {
String credits = String.format("Current Location \n Longitude: %1$s \n Latitude: %2$s", location.getLongitude(), location.getLatitude());
Double number = Double.valueOf(credits);
DecimalFormat dec = new DecimalFormat("#.000 EUR");
String message = dec.format(number);
Toast.makeText(Clockin.this, message, Toast.LENGTH_SHORT).show();
//txt.setText(message);
System.out.println("GPS.."+message);
}
Upvotes: 1
Views: 1276
Reputation: 22291
Use Below Code line
DecimalFormat dec = new DecimalFormat("#.###");
instead of
DecimalFormat dec = new DecimalFormat("#.000 EUR");
Upvotes: 7