From f610e6e7b7451efcbccefba881c5128973dcc94c Mon Sep 17 00:00:00 2001
From: fwq <582742538@qq.com>
Date: 星期一, 11 十二月 2023 10:41:37 +0800
Subject: [PATCH] 时间工具类优化

---
 src/main/java/com/hx/util/StringUtils.java |   56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 56 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/hx/util/StringUtils.java b/src/main/java/com/hx/util/StringUtils.java
index a25bd93..76e38a8 100644
--- a/src/main/java/com/hx/util/StringUtils.java
+++ b/src/main/java/com/hx/util/StringUtils.java
@@ -313,4 +313,60 @@
         return 0;
     }
 
+    /**
+     * 瀵瑰瓧绗︿覆锛堟墜鏈猴紝鍚嶇О锛変綔闅愯棌澶勭悊
+     * @param oriStr 鍘熷瀛楃涓�
+     * @param type 绫诲瀷0锛氬彧淇濈暀绗竴涓強鏈�鍚庝竴涓瓧绗︼紝鍏跺畠鐢�*鏇夸唬锛�1鍓�4鍚�3淇濈暀锛屼腑闂寸敤*鏇夸唬
+     * @return
+     */
+    public static String hideKeyWord(String oriStr, int type)
+    {
+        if(!isEmpty(oriStr))
+        {
+            String temp = null;
+
+            if(type == 0)
+            {
+                if(oriStr.length() == 1)
+                {
+                    temp = oriStr;
+                }else if(oriStr.length() == 2) {
+                    temp = oriStr.substring(0, 1) + "*";
+                }else if(oriStr.length() > 2) {
+                    temp = oriStr.substring(0, 1);
+                    for (int i = 1; i < oriStr.length() - 1; i++) {
+                        temp += "*";
+                    }
+                    temp += oriStr.substring(oriStr.length() - 1, oriStr.length());
+                }
+            }else{
+                if(oriStr.length() < 8)
+                {
+                    temp = oriStr;
+                }else{
+                    temp = oriStr.substring(0,3);
+                    for (int i = 3; i < oriStr.length() - 4; i++) {
+                        temp += "*";
+                    }
+                    temp += oriStr.substring(oriStr.length() - 4, oriStr.length());
+                }
+            }
+
+            return temp;
+        }
+
+        return oriStr;
+    }
+
+    /**
+     * 鍘婚櫎绌烘牸
+     * @param info 淇℃伅
+     * @return 杩斿洖
+     */
+    public static String trimBlank(String info){
+        if (null != info){
+            return info.trim();
+        }
+        return null;
+    }
 }

--
Gitblit v1.8.0