fix zero parsing error
This commit is contained in:
parent
a3757877a3
commit
befdbefa49
1 changed files with 6 additions and 0 deletions
|
@ -11,6 +11,8 @@ public class SafeParse {
|
||||||
public static Double stringToDouble(String input) {
|
public static Double stringToDouble(String input) {
|
||||||
Double result = 0d;
|
Double result = 0d;
|
||||||
input = input.replace(",", ".");
|
input = input.replace(",", ".");
|
||||||
|
if (input.equals(""))
|
||||||
|
return 0d;
|
||||||
try {
|
try {
|
||||||
result = Double.parseDouble(input);
|
result = Double.parseDouble(input);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -22,6 +24,8 @@ public class SafeParse {
|
||||||
public static Integer stringToInt(String input) {
|
public static Integer stringToInt(String input) {
|
||||||
Integer result = 0;
|
Integer result = 0;
|
||||||
input = input.replace(",", ".");
|
input = input.replace(",", ".");
|
||||||
|
if (input.equals(""))
|
||||||
|
return 0;
|
||||||
try {
|
try {
|
||||||
result = Integer.parseInt(input);
|
result = Integer.parseInt(input);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -33,6 +37,8 @@ public class SafeParse {
|
||||||
public static Long stringToLong(String input) {
|
public static Long stringToLong(String input) {
|
||||||
Long result = 0L;
|
Long result = 0L;
|
||||||
input = input.replace(",", ".");
|
input = input.replace(",", ".");
|
||||||
|
if (input.equals(""))
|
||||||
|
return 0L;
|
||||||
try {
|
try {
|
||||||
result = Long.parseLong(input);
|
result = Long.parseLong(input);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
Loading…
Reference in a new issue