1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
/** 转换字符串为数字 */
public
static
int
strToInt(
String
value,
int
defaultValue) {
try
{
return
Integer.valueOf(value);
}
catch
(Exception e) {
return
defaultValue;
}
}
/** 转换字符串为数字 */
public
static
long strToInt(
String
value, long defaultValue) {
try
{
return
Long.valueOf(value);
}
catch
(Exception e) {
return
defaultValue;
}
}
/** 转换16进制字符串为数字 */
public
static
int
hexToInt(
String
value,
int
defaultValue) {
try
{
return
Integer.
parseInt
(value,
16
);
}
catch
(Exception e) {
return
defaultValue;
}
}
/** 转换16进制字符串为数字 */
public
static
long hexToInt(
String
value, long defaultValue) {
try
{
return
Long.parseLong(value,
16
);
}
catch
(Exception e) {
return
defaultValue;
}
}
/** 转换字符串为数字 */
public
static
float strToFloat(
String
value, float defaultValue) {
try
{
return
Float.valueOf(value);
}
catch
(Exception e) {
return
defaultValue;
}
}
/** 转换字符串为数字 */
public
static
double strToDouble(
String
value, double defaultValue) {
try
{
return
Double.valueOf(value);
}
catch
(Exception e) {
return
defaultValue;
}
}
|