diff --git a/OsmAnd-java/src/main/java/net/osmand/util/Algorithms.java b/OsmAnd-java/src/main/java/net/osmand/util/Algorithms.java index 36c0034a26..05da55a753 100644 --- a/OsmAnd-java/src/main/java/net/osmand/util/Algorithms.java +++ b/OsmAnd-java/src/main/java/net/osmand/util/Algorithms.java @@ -117,6 +117,13 @@ public class Algorithms { } return def; } + + public static String formatDoubleWithoutAdditionalZeros(double d) { + if(d == (long) d) + return String.format(Locale.US, "%d",(long)d); + else + return String.format("%s",d); + } public static int parseIntSilently(String input, int def) { if (input != null && input.length() > 0) { diff --git a/OsmAnd/src/net/osmand/plus/OsmAndFormatter.java b/OsmAnd/src/net/osmand/plus/OsmAndFormatter.java index 6a52fe9804..d18309730e 100644 --- a/OsmAnd/src/net/osmand/plus/OsmAndFormatter.java +++ b/OsmAnd/src/net/osmand/plus/OsmAndFormatter.java @@ -121,13 +121,19 @@ public class OsmAndFormatter { } public static String getFormattedTimeInterval(OsmandApplication app, double interval) { + String units; + double intervalInUnits; if (interval < 60) { - return interval + " " + app.getString(R.string.int_seconds); + units = app.getString(R.string.shared_string_sec); + intervalInUnits = interval; } else if (interval % 60 == 0) { - return (interval / 60) + " " + app.getString(R.string.int_min); + units = app.getString(R.string.int_min); + intervalInUnits = (interval / 60); } else { - return (interval / 60f) + " " + app.getString(R.string.int_min); + units = app.getString(R.string.int_min); + intervalInUnits = (interval / 60f); } + return Algorithms.formatDoubleWithoutAdditionalZeros(intervalInUnits) + " " + units; } public static String getFormattedDistanceInterval(OsmandApplication app, double interval) {