log SafeParse

This commit is contained in:
Milos Kozak 2017-03-05 20:12:30 +01:00
parent ccca820a95
commit af8e485250

View file

@ -1,15 +1,20 @@
package info.nightscout.utils; package info.nightscout.utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* Created by mike on 23.06.2016. * Created by mike on 23.06.2016.
*/ */
public class SafeParse { public class SafeParse {
private static Logger log = LoggerFactory.getLogger(SafeParse.class);
public static Double stringToDouble(String input) { public static Double stringToDouble(String input) {
Double result = 0d; Double result = 0d;
input = input.replace(",", "."); input = input.replace(",", ".");
try { try {
result = Double.parseDouble(input); result = Double.parseDouble(input);
} catch (Exception e) { } catch (Exception e) {
log.error("Error parsing " + input + " to double");
} }
return result; return result;
} }
@ -20,6 +25,7 @@ public class SafeParse {
try { try {
result = Integer.parseInt(input); result = Integer.parseInt(input);
} catch (Exception e) { } catch (Exception e) {
log.error("Error parsing " + input + " to int");
} }
return result; return result;
} }
@ -30,6 +36,7 @@ public class SafeParse {
try { try {
result = Long.parseLong(input); result = Long.parseLong(input);
} catch (Exception e) { } catch (Exception e) {
log.error("Error parsing " + input + " to long");
} }
return result; return result;
} }