mirror of
https://gitee.com/jzsw-it/yexuejc-base.git
synced 2025-09-28 08:23:20 +08:00
1.1.9
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
package com.yexuejc.base.util;
|
||||
|
||||
|
||||
import sun.misc.BASE64Decoder;
|
||||
|
||||
/**
|
||||
* 算法工具类
|
||||
*
|
||||
@@ -11,13 +9,13 @@ import sun.misc.BASE64Decoder;
|
||||
* @author: maxf
|
||||
* @date: 2017年11月23日 下午3:17:58
|
||||
*/
|
||||
public class AlgorithmUtils {
|
||||
public class AlgorithmUtil {
|
||||
private static final int LENGTH_1 = 1;
|
||||
private static final int LENGTH_2 = 2;
|
||||
private static final int LENGTH_3 = 3;
|
||||
private static final int LENGTH_36 = 36;
|
||||
|
||||
private AlgorithmUtils() {
|
||||
private AlgorithmUtil() {
|
||||
}
|
||||
|
||||
private static final String X36 = "0123456789abcdefghijklmnopqrstuvwxyz";
|
@@ -13,6 +13,9 @@ import java.util.Date;
|
||||
* @date: 2018/3/27 10:44
|
||||
*/
|
||||
public class DateTimeUtil {
|
||||
private DateTimeUtil() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取本年第一天
|
||||
*
|
||||
@@ -106,7 +109,8 @@ public class DateTimeUtil {
|
||||
* @return
|
||||
*/
|
||||
public static LocalDate getWeek4First(LocalDate date) {
|
||||
TemporalAdjuster FIRST_OF_WEEK = TemporalAdjusters.ofDateAdjuster(localDate -> localDate.minusDays(localDate.getDayOfWeek().getValue() - DayOfWeek.MONDAY.getValue()));
|
||||
TemporalAdjuster FIRST_OF_WEEK =
|
||||
TemporalAdjusters.ofDateAdjuster(localDate -> localDate.minusDays(localDate.getDayOfWeek().getValue() - DayOfWeek.MONDAY.getValue()));
|
||||
return date.with(FIRST_OF_WEEK);
|
||||
}
|
||||
|
||||
@@ -126,7 +130,8 @@ public class DateTimeUtil {
|
||||
* @return
|
||||
*/
|
||||
public static LocalDate getWeek4Last(LocalDate date) {
|
||||
TemporalAdjuster LAST_OF_WEEK = TemporalAdjusters.ofDateAdjuster(localDate -> localDate.plusDays(DayOfWeek.SUNDAY.getValue() - localDate.getDayOfWeek().getValue()));
|
||||
TemporalAdjuster LAST_OF_WEEK =
|
||||
TemporalAdjusters.ofDateAdjuster(localDate -> localDate.plusDays(DayOfWeek.SUNDAY.getValue() - localDate.getDayOfWeek().getValue()));
|
||||
return date.with(LAST_OF_WEEK);
|
||||
}
|
||||
|
||||
|
@@ -6,12 +6,14 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* java.util.Date 时间工具类
|
||||
* @ClassName DateUtil
|
||||
* java.util.Date 时间工具类
|
||||
*
|
||||
* @author maxf
|
||||
* @ClassName DateUtil
|
||||
* @Description
|
||||
* @author maxf
|
||||
* @date 2018/9/3 15:27
|
||||
* @date 2018/9/3 15:27
|
||||
*/
|
||||
public class DateUtil {
|
||||
private DateUtil() {
|
||||
@@ -87,7 +89,7 @@ public class DateUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 日期字符串转date
|
||||
* date转字符串
|
||||
*
|
||||
* @param date
|
||||
* @return Date
|
||||
@@ -101,6 +103,34 @@ public class DateUtil {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 日期字符串转dateTime
|
||||
*
|
||||
* @param dateStr
|
||||
* @return
|
||||
* @throws ParseException
|
||||
*/
|
||||
public static Date str2dateTime(String dateStr) throws ParseException {
|
||||
Date date = DATE_TIME_FORMAT.parse(dateStr);
|
||||
return date;
|
||||
}
|
||||
|
||||
/**
|
||||
* dateTime转字符串
|
||||
*
|
||||
* @param date
|
||||
* @return Date
|
||||
* @throws ParseException
|
||||
*/
|
||||
public static String dateTime2str(Date date) throws ParseException {
|
||||
if (date != null) {
|
||||
return DATE_TIME_FORMAT.format(date);
|
||||
} else {
|
||||
return "null";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取本周的日期
|
||||
*
|
||||
|
@@ -8,8 +8,9 @@ package com.yexuejc.base.util;
|
||||
* @author: maxf
|
||||
* @date: 2017/12/27 16:42
|
||||
*/
|
||||
public class ExcelImportUtils {
|
||||
|
||||
public class ExcelImportUtil {
|
||||
private ExcelImportUtil() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是2003的excel,返回true是2003
|
@@ -22,6 +22,8 @@ import java.util.Iterator;
|
||||
* @date 2018/9/3 15:25
|
||||
*/
|
||||
public class ImgUtil {
|
||||
private ImgUtil() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 将一张网络图片转化成Base64字符串
|
||||
|
@@ -8,65 +8,59 @@ import java.util.Map;
|
||||
|
||||
/**
|
||||
* jwt工具类
|
||||
* <p>
|
||||
* 升级2.0
|
||||
* <br/>
|
||||
* 由静态类分装成单例类,可配置参数config()
|
||||
* </p>
|
||||
*
|
||||
* @author maxf
|
||||
* @version 2.0
|
||||
* @ClassName JwtUtil
|
||||
* @Description
|
||||
* @date 2018/9/3 15:28
|
||||
*/
|
||||
public class JwtUtil {
|
||||
/**
|
||||
* 加密用KEY
|
||||
*/
|
||||
private static String JWT_SIGNATURE_KEY = "h%OG8Y3WgA5AN7&6Ke7I#C1XvneW0N8a";
|
||||
/**
|
||||
* token类型
|
||||
*/
|
||||
private static String JWT_HEADER_TYP = "JWT";
|
||||
/**
|
||||
* token发行商
|
||||
*/
|
||||
private static String JWT_CLAIMS_ISS = "yexuejc.com";
|
||||
|
||||
private JwtUtil() {
|
||||
}
|
||||
|
||||
public static JwtUtil instace() {
|
||||
return Instace.jwtUtil;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置配置
|
||||
* 参数配置:设置一次即可,多次设置会覆盖之前的
|
||||
*
|
||||
* @param key
|
||||
* @param type
|
||||
* @param iss
|
||||
* @param key 加密key 默认:h%OG8Y3WgA5AN7&6Ke7I#C1XvneW0N8a
|
||||
* @param type 加密类型:默认JWT
|
||||
* @param iss token发行商: 默认yexuejc.com
|
||||
* @return
|
||||
*/
|
||||
public static void setConf(String key, String type, String iss) {
|
||||
JWT_SIGNATURE_KEY = key;
|
||||
JWT_HEADER_TYP = type;
|
||||
JWT_CLAIMS_ISS = iss;
|
||||
public static JwtUtil config(String key, String type, String iss) {
|
||||
JwtUtil jwtUtil = instace();
|
||||
jwtUtil.JWT_SIGNATURE_KEY = key;
|
||||
jwtUtil.JWT_HEADER_TYP = type;
|
||||
jwtUtil.JWT_CLAIMS_ISS = iss;
|
||||
return jwtUtil;
|
||||
}
|
||||
|
||||
public static class Instace {
|
||||
private static JwtUtil jwtUtil = new JwtUtil();
|
||||
}
|
||||
|
||||
/**
|
||||
* 加密用KEY
|
||||
*
|
||||
* @param key
|
||||
*/
|
||||
public static void setSignatureKey(String key) {
|
||||
JWT_SIGNATURE_KEY = key;
|
||||
}
|
||||
|
||||
private String JWT_SIGNATURE_KEY = "h%OG8Y3WgA5AN7&6Ke7I#C1XvneW0N8a";
|
||||
/**
|
||||
* token类型
|
||||
*
|
||||
* @param type
|
||||
*/
|
||||
public static void setHeaderType(String type) {
|
||||
JWT_HEADER_TYP = type;
|
||||
}
|
||||
|
||||
private String JWT_HEADER_TYP = "JWT";
|
||||
/**
|
||||
* token发行商
|
||||
*
|
||||
* @param iss
|
||||
*/
|
||||
public static void setClaimsIss(String iss) {
|
||||
JWT_CLAIMS_ISS = iss;
|
||||
}
|
||||
private String JWT_CLAIMS_ISS = "yexuejc.com";
|
||||
|
||||
/**
|
||||
* 加密内容生成token
|
||||
@@ -74,7 +68,7 @@ public class JwtUtil {
|
||||
* @param subjectObj
|
||||
* @return
|
||||
*/
|
||||
public static String compact(Object subjectObj) {
|
||||
public String compact(Object subjectObj) {
|
||||
String subject = null;
|
||||
if (subjectObj instanceof String) {
|
||||
subject = (String) subjectObj;
|
||||
@@ -106,7 +100,7 @@ public class JwtUtil {
|
||||
* @param token
|
||||
* @return
|
||||
*/
|
||||
public static Map<?, ?> parse(String token) {
|
||||
public Map<?, ?> parse(String token) {
|
||||
return parse(token, Map.class);
|
||||
}
|
||||
|
||||
@@ -117,7 +111,7 @@ public class JwtUtil {
|
||||
* @param cls
|
||||
* @return
|
||||
*/
|
||||
public static <T> T parse(String token, Class<T> cls) {
|
||||
public <T> T parse(String token, Class<T> cls) {
|
||||
String subject = null;
|
||||
try {
|
||||
subject = Jwts.parser().setSigningKey(JWT_SIGNATURE_KEY).parseClaimsJws(token).getBody().getSubject();
|
||||
|
@@ -11,8 +11,8 @@ import java.text.DecimalFormat;
|
||||
* @author: maxf
|
||||
* @date: 2017年12月1日 下午5:33:57
|
||||
*/
|
||||
public class MoneyUtils {
|
||||
private MoneyUtils() {
|
||||
public class MoneyUtil {
|
||||
private MoneyUtil() {
|
||||
}
|
||||
|
||||
/**
|
@@ -10,8 +10,8 @@ import java.util.regex.Pattern;
|
||||
* @expl
|
||||
* @time 2017年11月9日 上午11:01:24
|
||||
*/
|
||||
public class RegexUtils {
|
||||
private RegexUtils() {
|
||||
public class RegexUtil {
|
||||
private RegexUtil() {
|
||||
}
|
||||
|
||||
/**
|
@@ -16,6 +16,9 @@ import java.util.regex.Pattern;
|
||||
* @date: 2018/5/12 19:13
|
||||
*/
|
||||
public final class StrUtil {
|
||||
private StrUtil() {
|
||||
}
|
||||
|
||||
public static char[] HEX_CHAR = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
|
||||
|
||||
/**
|
||||
|
@@ -10,10 +10,10 @@ import java.net.URL;
|
||||
* @author: maxf
|
||||
* @date: 2017/12/28 16:12
|
||||
*/
|
||||
public class SysUtils {
|
||||
public class SysUtil {
|
||||
private static final String PROJECT_ROOT_PATH = "java.io.tmpdir";
|
||||
|
||||
private SysUtils() {
|
||||
private SysUtil() {
|
||||
}
|
||||
|
||||
/**
|
@@ -20,6 +20,8 @@ import java.security.Key;
|
||||
* @date 2018/9/3 17:09
|
||||
*/
|
||||
public class ThreeDES {
|
||||
private ThreeDES() {
|
||||
}
|
||||
|
||||
private static final String IV = "1234567-";
|
||||
private final static String encoding = "utf-8";
|
||||
|
Reference in New Issue
Block a user