remove zeros from time formatting
This commit is contained in:
parent
1c5d01f391
commit
e1d1edee43
2 changed files with 16 additions and 3 deletions
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue