mirror of
https://github.com/wahyd4/pinpoint.git
synced 2026-08-24 12:16:33 +10:00
git-svn-id: http://svn.bds.nhncorp.com/pe/hippo-tomcat-profiler/trunk@1163 84d0f5b1-2673-498c-a247-62c4ff18d310
49 lines
1.2 KiB
Java
49 lines
1.2 KiB
Java
package com.profiler.util;
|
|
|
|
public class NumberUtils {
|
|
public static long parseLong(String str, long defaultLong) {
|
|
if (str == null) {
|
|
return defaultLong;
|
|
}
|
|
try {
|
|
return Long.parseLong(str);
|
|
} catch (NumberFormatException e) {
|
|
return defaultLong;
|
|
}
|
|
}
|
|
|
|
public static int parseInteger(String str, int defaultInt) {
|
|
if (str == null) {
|
|
return defaultInt;
|
|
}
|
|
try {
|
|
return Integer.parseInt(str);
|
|
} catch (NumberFormatException e) {
|
|
return defaultInt;
|
|
}
|
|
}
|
|
|
|
public static short parseShort(String str, short defaultInt) {
|
|
if (str == null) {
|
|
return defaultInt;
|
|
}
|
|
try {
|
|
return Short.parseShort(str);
|
|
} catch (NumberFormatException e) {
|
|
return defaultInt;
|
|
}
|
|
}
|
|
|
|
public static Integer toInteger(Object integer) {
|
|
if (integer == null) {
|
|
return null;
|
|
}
|
|
if (integer instanceof Integer) {
|
|
return (Integer) integer;
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
}
|