From c7bcef9d03f58c984d475932710c247ee778d95b Mon Sep 17 00:00:00 2001 From: lsh <1> Date: 星期二, 09 四月 2024 23:31:39 +0800 Subject: [PATCH] # --- src/main/java/com/zy/common/utils/CommonUtils.java | 24 ++++++++++++++++++++++++ 1 files changed, 24 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/zy/common/utils/CommonUtils.java b/src/main/java/com/zy/common/utils/CommonUtils.java index d3233b7..8a2e8b6 100644 --- a/src/main/java/com/zy/common/utils/CommonUtils.java +++ b/src/main/java/com/zy/common/utils/CommonUtils.java @@ -27,4 +27,28 @@ } } + public static boolean isNumeric(String str) { + // 濡傛灉瀛楃涓蹭负绌猴紝鐩存帴杩斿洖false + if (str == null || str.length() == 0) { + return false; + } + // 鐢ㄦ鍒欒〃杈惧紡鍖归厤鏁板瓧 + return str.matches("-?\\d+(\\.\\d+)?"); + } + + public static boolean isBoolean(String str) { + if (str == null) { + return false; + } + + if (str.length() == 4 || str.length() == 5) { + if (str.equals("true") || str.equals("false")) { + return true; + } + } + + return false; + } + + } -- Gitblit v1.9.1