From 6bf1d82318759bd9d4a7c8d6dd043933d1f253e9 Mon Sep 17 00:00:00 2001 From: jacques Date: Sat, 12 Mar 2022 21:18:44 +0100 Subject: [PATCH] Add format string method --- app/src/main/java/net/foucry/pilldroid/Utils.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/src/main/java/net/foucry/pilldroid/Utils.java b/app/src/main/java/net/foucry/pilldroid/Utils.java index 0db4c80..bff52ba 100644 --- a/app/src/main/java/net/foucry/pilldroid/Utils.java +++ b/app/src/main/java/net/foucry/pilldroid/Utils.java @@ -8,6 +8,7 @@ import android.util.Log; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.util.Locale; import java.util.Random; public class Utils { @@ -45,4 +46,12 @@ public class Utils { Random r = new Random(); return r.nextInt(max - min) +max; } + + public static String fmt(double d) + { + if(d == (long) d) + return String.format(Locale.getDefault(),"%d",(long)d); + else + return String.format("%s",d); + } }