Here you can find the source of roundDistanceFromMeterToKm(final double distanceInMeter)
Parameter | Description |
---|---|
distanceInMeter | a parameter |
public static String roundDistanceFromMeterToKm(final double distanceInMeter)
//package com.java2s; //License from project: LGPL import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; public class Main { private static final int KILOMETER_IN_METER = 1000; /**//w w w . j a v a2 s. c o m * z.B. aus 10123.234535 --> 10.123 * * @param distanceInMeter * @return distanz in kilometer, gerundet auf einen meter */ public static String roundDistanceFromMeterToKm(final double distanceInMeter) { final double distanceInKilometer = distanceInMeter / KILOMETER_IN_METER; final DecimalFormat format = new DecimalFormat("0.000"); //$NON-NLS-1$ final DecimalFormatSymbols dfs = new DecimalFormatSymbols(); dfs.setDecimalSeparator('.'); format.setDecimalFormatSymbols(dfs); return format.format(distanceInKilometer); } }