mirror of
https://github.com/wahyd4/pinpoint.git
synced 2026-08-19 09:47:27 +10:00
git-svn-id: http://svn.bds.nhncorp.com/pe/hippo-tomcat-profiler/trunk@626 84d0f5b1-2673-498c-a247-62c4ff18d310
38 lines
910 B
Java
38 lines
910 B
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 Integer toInteger(Object integer) {
|
|
if(integer == null) {
|
|
return null;
|
|
}
|
|
if (integer instanceof Integer) {
|
|
return (Integer)integer;
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
}
|