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(",", ".");
        if (input.equals(""))
            return 0d;
        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(",", ".");
        if (input.equals(""))
            return 0;
        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(",", ".");
       if (input.equals(""))
           return 0L;
        try {
            result = Long.parseLong(input);
        } catch (Exception e) {
            log.error("Error parsing " + input + " to long");
        }
        return result;
    }
}

@@ -341,32 +341,73 @@
 lace(%22,%22, %22.%22);%0A
+        input = input.replace(%22%E2%88%92%22, %22-%22);%0A
         if (inpu
@@ -412,32 +412,32 @@
 put.equals(%22%22))%0A
-
             retu
@@ -756,32 +756,73 @@
 lace(%22,%22, %22.%22);%0A
+        input = input.replace(%22%E2%88%92%22, %22-%22);%0A
         if (inpu
@@ -1123,24 +1123,24 @@
 esult = 0L;%0A
-
         inpu
@@ -1164,24 +1164,65 @@
 (%22,%22, %22.%22);%0A
+        input = input.replace(%22%E2%88%92%22, %22-%22);%0A
        if (i

replace swedish minus sign with default minus sign