zjh
2024-12-03 06ef175a1e9f72b3863757319b2f6ff76c5a2f05
ltkj-admin/src/test/java/zjhTest.java
@@ -9,6 +9,7 @@
import com.ltkj.LtkjApplication;
import com.ltkj.common.core.redis.RedisCache;
import com.ltkj.common.utils.SecurityUtils;
import com.ltkj.common.utils.StringUtils;
import com.ltkj.framework.config.MatchUtils;
import com.ltkj.hosp.domain.DictHosp;
import com.ltkj.hosp.domain.TjCustomer;
@@ -33,6 +34,7 @@
import javax.annotation.Resource;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.net.HttpURLConnection;
import java.net.URL;
import java.sql.Connection;
@@ -46,6 +48,8 @@
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
 * @Author: 西安路泰科技有限公司/赵佳豪
@@ -129,13 +133,54 @@
        public static void main(String[] args) {
//            System.out.println(DateUtil.date());
//            System.out.println(DateUtil.offsetMonth(DateUtil.date(),-1));
        String s ="612129197611110029";
        String ss ="13335337160";
            boolean idCard = MatchUtils.isIdCard(s);
            System.out.println(idCard);
            System.out.println(MatchUtils.isMobileNO(ss));
        }
    /**
     * 将科学计数法文本转换成字符文本
     * @param number
     * @return
     */
    public static String translateToPlainStr(String number) {
        return getString(number);
    }
    private static String getString(String number) {
        if (null == number || number.trim().length() == 0) {
            return number;
        }
        String regEx="^([\\+|-]?\\d+(.{0}|.\\d+))[Ee]{1}([\\+|-]?\\d+)$";
        // 编译正则表达式
        Pattern pattern = Pattern.compile(regEx);
        // 忽略大小写的写法
        // Pattern pat = Pattern.compile(regEx, Pattern.CASE_INSENSITIVE);
        Matcher matcher = pattern.matcher(number);
        // 字符串是否与正则表达式相匹配
        boolean rs = matcher.matches();
        // 判断是否为字符串的科学计数法
        if(rs){
            // 科学计数法转数字
            BigDecimal originValue = new BigDecimal(number);
            System.out.println("手机号为 ==> " + originValue.toPlainString());
            // 数字转字符串
            return originValue.toPlainString();
        }
        return number;
    }
        public static void forwardUrl(String targetUrl, String forwardUrl) throws Exception {
    public static void forwardUrl(String targetUrl, String forwardUrl) throws Exception {
            // 创建URL对象
            URL url = new URL(forwardUrl);