From befdbefa499990e0637eb02f0aa484f384bad5c6 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 20 Jun 2017 19:58:43 +0200 Subject: [PATCH] fix zero parsing error --- app/src/main/java/info/nightscout/utils/SafeParse.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/src/main/java/info/nightscout/utils/SafeParse.java b/app/src/main/java/info/nightscout/utils/SafeParse.java index 8697daeebd..ff749f732b 100644 --- a/app/src/main/java/info/nightscout/utils/SafeParse.java +++ b/app/src/main/java/info/nightscout/utils/SafeParse.java @@ -11,6 +11,8 @@ public class SafeParse { public static Double stringToDouble(String input) { Double result = 0d; input = input.replace(",", "."); + if (input.equals("")) + return 0d; try { result = Double.parseDouble(input); } catch (Exception e) { @@ -22,6 +24,8 @@ public class SafeParse { public static Integer stringToInt(String input) { Integer result = 0; input = input.replace(",", "."); + if (input.equals("")) + return 0; try { result = Integer.parseInt(input); } catch (Exception e) { @@ -33,6 +37,8 @@ public class SafeParse { public static Long stringToLong(String input) { Long result = 0L; input = input.replace(",", "."); + if (input.equals("")) + return 0L; try { result = Long.parseLong(input); } catch (Exception e) {