log SafeParse
This commit is contained in:
parent
ccca820a95
commit
af8e485250
|
@ -1,15 +1,20 @@
|
|||
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;
|
||||
}
|
||||
|
@ -20,6 +25,7 @@ public class SafeParse {
|
|||
try {
|
||||
result = Integer.parseInt(input);
|
||||
} catch (Exception e) {
|
||||
log.error("Error parsing " + input + " to int");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -30,6 +36,7 @@ public class SafeParse {
|
|||
try {
|
||||
result = Long.parseLong(input);
|
||||
} catch (Exception e) {
|
||||
log.error("Error parsing " + input + " to long");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue