AndroidAPS/app/src/main/java/info/nightscout/utils/SafeParse.java

37 lines
862 B
Java
Raw Normal View History

2016-06-23 17:07:38 +02:00
package info.nightscout.utils;
/**
* Created by mike on 23.06.2016.
*/
public class SafeParse {
public static Double stringToDouble(String input) {
Double result = 0d;
input = input.replace(",", ".");
try {
result = Double.parseDouble(input);
} catch (Exception e) {
}
return result;
}
public static Integer stringToInt(String input) {
Integer result = 0;
input = input.replace(",", ".");
try {
result = Integer.parseInt(input);
} catch (Exception e) {
}
return result;
}
2016-08-07 13:07:13 +02:00
public static Long stringToLong(String input) {
Long result = 0L;
input = input.replace(",", ".");
try {
result = Long.parseLong(input);
} catch (Exception e) {
}
return result;
}
2016-06-23 17:07:38 +02:00
}