package info.nightscout.utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Created by mike on 23.06.2016.
 */
public class SafeParse {
    private static Logger log = LoggerFactory.getLogger(SafeParse.class);
    public static Double stringToDouble(String input) {
        Double result = 0d;
        input = input.replace(",", ".");
        try {
            result = Double.parseDouble(input);
        } catch (Exception e) {
            log.error("Error parsing " + input + " to double");
        }
        return result;
    }

    public static Integer stringToInt(String input) {
        Integer result = 0;
        input = input.replace(",", ".");
        try {
            result = Integer.parseInt(input);
        } catch (Exception e) {
            log.error("Error parsing " + input + " to int");
        }
        return result;
    }

   public static Long stringToLong(String input) {
        Long result = 0L;
        input = input.replace(",", ".");
        try {
            result = Long.parseLong(input);
        } catch (Exception e) {
            log.error("Error parsing " + input + " to long");
        }
        return result;
    }
}

@@ -341,32 +341,85 @@
 lace(%22,%22, %22.%22);%0A
+        if (input.equals(%22%22))%0A            return 0d;%0A
         try %7B%0A  
@@ -408,32 +408,32 @@
 ;%0A        try %7B%0A
-
             resu
@@ -715,32 +715,84 @@
 lace(%22,%22, %22.%22);%0A
+        if (input.equals(%22%22))%0A            return 0;%0A
         try %7B%0A  
@@ -1045,16 +1045,16 @@
 t = 0L;%0A
-
         
@@ -1078,32 +1078,83 @@
 lace(%22,%22, %22.%22);%0A
+       if (input.equals(%22%22))%0A           return 0L;%0A
         try %7B%0A  

fix zero parsing error