48 lines
929 B
Java
48 lines
929 B
Java
package com.kri.common.util;
|
|
|
|
import java.util.UUID;
|
|
|
|
public final class CommonUtil {
|
|
|
|
public static String uuid32() {
|
|
return UUID.randomUUID().toString().replace("-", "");
|
|
}
|
|
|
|
public static boolean isNumeric(String s) {
|
|
if (s == null || s.isBlank()) {
|
|
return false;
|
|
}
|
|
for (int i = 0; i < s.length(); i++) {
|
|
char c = s.charAt(i);
|
|
if (c < '0' || c > '9') {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public static short safeParseShort(String s, short def) {
|
|
try {
|
|
return Short.parseShort(s);
|
|
} catch (Exception e) {
|
|
return def;
|
|
}
|
|
}
|
|
|
|
public static int safeParseInt(String s, short def) {
|
|
try {
|
|
return Integer.parseInt(s);
|
|
} catch (Exception e) {
|
|
return def;
|
|
}
|
|
}
|
|
|
|
public static long safeParseLong(String s, short def) {
|
|
try {
|
|
return Long.parseLong(s);
|
|
} catch (Exception e) {
|
|
return def;
|
|
}
|
|
}
|
|
}
|