From 76b630351b2db4b3dbc5c427f5d8edb5d488872c Mon Sep 17 00:00:00 2001 From: ChenJiaHe <763432473@qq.com> Date: 星期五, 21 五月 2021 10:55:28 +0800 Subject: [PATCH] 月增加时间处理 --- src/main/java/com/hx/util/StringUtils.java | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 55 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/hx/util/StringUtils.java b/src/main/java/com/hx/util/StringUtils.java index 6710290..78d4e36 100644 --- a/src/main/java/com/hx/util/StringUtils.java +++ b/src/main/java/com/hx/util/StringUtils.java @@ -228,6 +228,16 @@ return null == str || str.trim().length() == 0 || "undefined".equals(str); } + /**鍒ゆ柇绌�*/ + public static boolean isNull(String str) { + return null == str || str.trim().length() == 0 || "undefined".equals(str); + } + + /**鍒ゆ柇闈炵┖*/ + public static boolean noNull(String str) { + return null != str && str.trim().length() != 0 && !"undefined".equals(str); + } + /** * 鍒ゆ柇瀛楃鍐呭涓槸鍚﹀瓨鍦ㄤ竴涓负绌虹殑瀛楃锟�? * <p> @@ -303,4 +313,49 @@ 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; + } + } -- Gitblit v1.8.0