whyclxw
2025-05-28 e16302f9d475c7cc4dd18c5abf1a23cb5502e362
src/main/java/com/whyc/util/ThreadLocalUtil.java
@@ -10,6 +10,8 @@
    public static ThreadLocal<SimpleDateFormat> sdfwithday = ThreadLocal.withInitial(() -> new SimpleDateFormat("yyyy-MM-dd"));
    public static ThreadLocal<SimpleDateFormat> sdfwithtime = ThreadLocal.withInitial(() -> new SimpleDateFormat("HH:mm:ss"));
    public static ThreadLocal<SimpleDateFormat> sdfwithTABLE=ThreadLocal.withInitial(() -> new SimpleDateFormat("yyyy-MM"));
    public static ThreadLocal<SimpleDateFormat> sdfwithtime_yyyyMMdd_HH_mm_ss=ThreadLocal.withInitial(() -> new SimpleDateFormat("yyyy-MM-dd_HH_mm_ss"));
    public static ThreadLocal<SimpleDateFormat> YYYY_MM_DD_HH_MM_SS_UNION=ThreadLocal.withInitial(() -> new SimpleDateFormat("yyyyMMddHHmmss"));
    /*
    * flag:1(sdf),2(sdfwithOutday),3(sdfwithday),4(sdfwithtime)
@@ -22,7 +24,6 @@
                case 2:date=sdfwithOutday.get().parse(timeStr);break;
                case 3:date=sdfwithday.get().parse(timeStr);break;
                case 4:date=sdfwithtime.get().parse(timeStr);break;
                case 5:date=sdfwithTABLE.get().parse(timeStr);break;
                default:date=sdf.get().parse(timeStr);
            }
        } catch (ParseException e) {
@@ -38,6 +39,8 @@
            case 3:timeStr=sdfwithday.get().format(date);break;
            case 4:timeStr=sdfwithtime.get().format(date);break;
            case 5:timeStr=sdfwithTABLE.get().format(date);break;
            case 6:timeStr=sdfwithtime_yyyyMMdd_HH_mm_ss.get().format(date);break;
            case 7:timeStr=YYYY_MM_DD_HH_MM_SS_UNION.get().format(date);break;
            default:timeStr=sdf.get().format(date);
        }
        return timeStr;