From 135164d5a63a49eb51809abd99445b1ca20e7209 Mon Sep 17 00:00:00 2001 From: wangrenhuang <wangren_huang@163.com> Date: 星期四, 17 二月 2022 10:53:45 +0800 Subject: [PATCH] 新增PTEncryptionUtil --- src/main/java/com/hx/encryption/PTEncryptionUtil.java | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 42 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/hx/encryption/PTEncryptionUtil.java b/src/main/java/com/hx/encryption/PTEncryptionUtil.java new file mode 100644 index 0000000..1239213 --- /dev/null +++ b/src/main/java/com/hx/encryption/PTEncryptionUtil.java @@ -0,0 +1,42 @@ +package com.hx.encryption; + +import com.hx.util.MD5Util; + +import java.util.Calendar; +import java.util.Date; + +/* + * @Description: his鍔╂墜璋冪敤 phitab 璁㈠崟鍔犲瘑宸ュ叿 + * @Author: wangrenhuang + * @Date: 2022/2/15-11:20 + */ +public class PTEncryptionUtil { + + /* + * 鏃ユ湡鍔犲瘑 + * date 瑕佸姞瀵嗙殑鏃ユ湡 + * */ + public static String encryption(Date date){ + Calendar cal=Calendar.getInstance(); + cal.setTime(date); + int year = cal.get(Calendar.YEAR);//鑾峰彇骞翠唤 + int month=cal.get(Calendar.MONTH);//鑾峰彇鏈堜唤 + int day=cal.get(Calendar.DATE);//鑾峰彇鏃� + int hour=cal.get(Calendar.HOUR_OF_DAY);//灏忔椂 + int minute=cal.get(Calendar.MINUTE);//鍒� + int second=cal.get(Calendar.SECOND);//绉� + + String yearStr = com.hx.mp.util.MD5Util.MD5Encode(year+"",""); + String monthStr = com.hx.mp.util.MD5Util.MD5Encode(month+"",""); + String dayStr = com.hx.mp.util.MD5Util.MD5Encode(day+"",""); + String hourStr = com.hx.mp.util.MD5Util.MD5Encode(hour+"",""); + String minuteStr = com.hx.mp.util.MD5Util.MD5Encode(minute+"",""); + String secondStr = com.hx.mp.util.MD5Util.MD5Encode(second+"",""); + + StringBuffer result = new StringBuffer(); + result.append(yearStr).append("-").append(monthStr).append("-").append(dayStr).append("-") + .append(hourStr).append("-").append(minuteStr).append("-").append(secondStr); + + return result.toString(); + } +} -- Gitblit v1.8.0