1 |
|
package net.jaekl.qd.util; |
2 |
|
|
3 |
Block: 0/1 |
public class ParseUtils { |
4 |
|
|
5 |
|
|
6 |
|
public static double parseDouble(String string) { |
7 |
Block: 1/1 |
if ((null == string) || ("".equals(string))) { |
8 |
Block: 1/1 Branch: 2/2 |
return 0.0; |
9 |
|
} |
10 |
|
try { |
11 |
Block: 1/1 Branch: 1/1 |
return Double.parseDouble(string); |
12 |
|
} |
13 |
Block: 1/1 |
catch (NumberFormatException exc) { |
14 |
|
return 0.0; |
15 |
|
} |
16 |
|
} |
17 |
|
|
18 |
|
public static int parseInt(String string) { |
19 |
Block: 1/1 |
if ((null == string) || ("".equals(string))) { |
20 |
Block: 1/1 Branch: 2/2 |
return 0; |
21 |
|
} |
22 |
|
try { |
23 |
Block: 1/1 Branch: 1/1 |
return Integer.parseInt(string); |
24 |
|
} |
25 |
Block: 1/1 |
catch (NumberFormatException exc) { |
26 |
|
return 0; |
27 |
|
} |
28 |
|
|
29 |
|
} |
30 |
|
} |