merge
This commit is contained in:
@@ -4,8 +4,6 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-demo
|
||||
* 创建时间: 2017/11/6 10:00
|
||||
* 作者: xiangwb
|
||||
* 说明: 公共数据类
|
||||
*/
|
||||
|
||||
@@ -12,7 +12,6 @@ import java.time.temporal.TemporalAdjusters;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 创建时间: 2017/1/9 17:11
|
||||
* 作者: xiangwb
|
||||
* 说明: 日期处理类
|
||||
*/
|
||||
@@ -333,7 +332,7 @@ public class DateUtil2 {
|
||||
LocalTime eTime = LocalTime.parse(endTime);
|
||||
Duration duration = Duration.between(sTime, eTime);
|
||||
long m = duration.toMinutes();
|
||||
return formate((double) m / 60.0, 1);
|
||||
return doubleFormat((double) m / 60.0, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -349,7 +348,7 @@ public class DateUtil2 {
|
||||
LocalDateTime eDateTime = LocalDateTime.parse(endDateTime, getDateFormat(YYYY_MM_DD_HH_MM));
|
||||
Duration duration = Duration.between(sDateTime, eDateTime);
|
||||
long m = duration.toMinutes();
|
||||
return formate((double) m / 60.0, 1);
|
||||
return doubleFormat((double) m / 60.0, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -449,11 +448,12 @@ public class DateUtil2 {
|
||||
|
||||
/**
|
||||
* 判断两者时间是否重合 重合返回true
|
||||
* 格式HH:mm:ss/HH:mm
|
||||
*
|
||||
* @param compareSTime 比较的时间段 09:00
|
||||
* @param compareETime 比较的时间段 13:00
|
||||
* @param needSTime 需要的时间段 09:00
|
||||
* @param needETime 需要的时间段 13:00
|
||||
* @param needSTime 需要的时间段
|
||||
* @param needETime 需要的时间段
|
||||
* @param compareSTime 比较的时间段
|
||||
* @param compareETime 比较的时间段
|
||||
* @return
|
||||
*/
|
||||
public static boolean compareTime(String needSTime, String needETime, String compareSTime, String compareETime) {
|
||||
@@ -461,25 +461,26 @@ public class DateUtil2 {
|
||||
|| needETime.compareTo(compareSTime) == 0)// 表示开始时间等于结束时间,或者结束时间等于开始时间
|
||||
return false;
|
||||
if (needSTime.compareTo(compareSTime) >= 0
|
||||
&& needSTime.compareTo(compareETime) < 0)// 需要时间开始时间在比较时间之间,表示已经重复了
|
||||
&& needSTime.compareTo(compareETime) < 0)// 需要时间开始时间在比较时间之间,表示已经重复了
|
||||
return true;
|
||||
if (needETime.compareTo(compareSTime) > 0
|
||||
&& needETime.compareTo(compareETime) <= 0) {// 需要时间结束时间在比较时间之间,表示已经重复了
|
||||
&& needETime.compareTo(compareETime) <= 0) {// 需要时间结束时间在比较时间之间,表示已经重复了
|
||||
return true;
|
||||
}
|
||||
if (needSTime.compareTo(compareSTime) < 0
|
||||
&& needETime.compareTo(compareETime) > 0)// 需要时间在比较时间前后,表示已经重复了
|
||||
&& needETime.compareTo(compareETime) > 0)// 需要时间在比较时间前后,表示已经重复了
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断两者时间是否重合 重合返回true
|
||||
* 格式yyyy-MM-dd
|
||||
*
|
||||
* @param compareSDate
|
||||
* @param compareEDate
|
||||
* @param needSDate
|
||||
* @param needEDate
|
||||
* @param needSDate 需要的时间段
|
||||
* @param needEDate 需要的时间段
|
||||
* @param compareSDate 比较的时间段
|
||||
* @param compareEDate 比较的时间段
|
||||
* @return
|
||||
*/
|
||||
public static boolean compareDate(String needSDate, String needEDate, String compareSDate, String compareEDate) {
|
||||
@@ -487,14 +488,14 @@ public class DateUtil2 {
|
||||
|| needEDate.compareTo(compareSDate) == 0)// 表示开始时间等于结束时间,或者结束时间等于开始时间
|
||||
return false;
|
||||
if (needSDate.compareTo(compareSDate) >= 0
|
||||
&& needSDate.compareTo(compareEDate) < 0)// 需要时间开始时间在比较时间之间,表示已经重复了
|
||||
&& needSDate.compareTo(compareEDate) < 0)// 需要时间开始时间在比较时间之间,表示已经重复了
|
||||
return true;
|
||||
if (needEDate.compareTo(compareSDate) > 0
|
||||
&& needEDate.compareTo(compareEDate) <= 0) {// 需要时间结束时间在比较时间之间,表示已经重复了
|
||||
&& needEDate.compareTo(compareEDate) <= 0) {// 需要时间结束时间在比较时间之间,表示已经重复了
|
||||
return true;
|
||||
}
|
||||
if (needSDate.compareTo(compareSDate) < 0
|
||||
&& needEDate.compareTo(compareEDate) > 0)// 需要时间在比较时间前后,表示已经重复了
|
||||
&& needEDate.compareTo(compareEDate) > 0)// 需要时间在比较时间前后,表示已经重复了
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
@@ -506,7 +507,7 @@ public class DateUtil2 {
|
||||
* @param scale
|
||||
* @return
|
||||
*/
|
||||
private static Double formate(Double v1, int scale) {
|
||||
private static Double doubleFormat(Double v1, int scale) {
|
||||
BigDecimal bg = new BigDecimal(v1);
|
||||
return bg.setScale(scale, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ import org.slf4j.LoggerFactory;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-demo
|
||||
* 创建时间: 2017/11/21 10:36
|
||||
* 作者: xiangwb
|
||||
* 说明: 数字工具类
|
||||
*/
|
||||
|
||||
@@ -12,7 +12,6 @@ import java.security.SecureRandom;
|
||||
|
||||
/**
|
||||
* 说明:散列算法(哈希算法)
|
||||
* 创建日期: 2016年11月29日 上午10:31:20
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
public class Digests {
|
||||
|
||||
@@ -12,7 +12,6 @@ import javax.mail.internet.*;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* 创建时间: 2016/11/7 10:11
|
||||
* 作者: xiangwb
|
||||
* 说明: 邮箱工具类
|
||||
*/
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.xwbing.util;
|
||||
|
||||
import org.apache.commons.codec.DecoderException;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.codec.binary.Hex;
|
||||
import org.apache.commons.lang3.StringEscapeUtils;
|
||||
import org.slf4j.Logger;
|
||||
@@ -10,10 +9,10 @@ import org.slf4j.LoggerFactory;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Base64;
|
||||
|
||||
/**
|
||||
* 说明:编码解码工具类
|
||||
* 创建日期: 2016年11月29日 上午10:30:34
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
public class EncodeUtils {
|
||||
@@ -43,11 +42,8 @@ public class EncodeUtils {
|
||||
* Base64编码.
|
||||
*/
|
||||
public static String base64Encode(byte[] input) {
|
||||
return new String(Base64.encodeBase64(input));
|
||||
/*
|
||||
* java8新特性
|
||||
*/
|
||||
// return java.util.Base64.getEncoder().encodeToString(input);//
|
||||
// return new String(org.apache.commons.codec.binary.Base64.encodeBase64(input));
|
||||
return Base64.getEncoder().encodeToString(input);
|
||||
}
|
||||
|
||||
|
||||
@@ -55,22 +51,16 @@ public class EncodeUtils {
|
||||
* Base64编码, URL安全(将Base64中的URL非法字符如+,/=转为其他字符, 见RFC3548).
|
||||
*/
|
||||
public static String base64UrlSafeEncode(byte[] input) {
|
||||
return Base64.encodeBase64URLSafeString(input);
|
||||
/**
|
||||
* java8新特性
|
||||
*/
|
||||
// return java.util.Base64.getUrlEncoder().encodeToString(input);
|
||||
// return Base64.encodeBase64URLSafeString(input);
|
||||
return java.util.Base64.getUrlEncoder().encodeToString(input);
|
||||
}
|
||||
|
||||
/**
|
||||
* Base64解码.
|
||||
*/
|
||||
public static byte[] base64Decode(String input) {
|
||||
return Base64.decodeBase64(input);
|
||||
/*
|
||||
* java8新特性
|
||||
*/
|
||||
// return java.util.Base64.getDecoder().decode(input);
|
||||
// return Base64.decodeBase64(input);
|
||||
return java.util.Base64.getDecoder().decode(input);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,8 +22,6 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-demo
|
||||
* 创建时间: 2017/11/20 17:07
|
||||
* 作者: xiangwb
|
||||
* 说明: excel导出工具类
|
||||
*/
|
||||
|
||||
@@ -30,8 +30,6 @@ import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-demo
|
||||
* 创建时间: 2017/11/21 10:36
|
||||
* 作者: xiangwb
|
||||
* 说明: HttpClientUtil
|
||||
*/
|
||||
|
||||
@@ -9,8 +9,6 @@ import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-demo
|
||||
* 创建时间: 2017/11/7 10:24
|
||||
* 作者: xiangwb
|
||||
* 说明:
|
||||
*/
|
||||
|
||||
@@ -8,7 +8,6 @@ import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* 说明: 封装对象结果的json结果
|
||||
* 创建日期: 2016年12月14日 下午3:20:05
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
@Data
|
||||
|
||||
@@ -14,7 +14,6 @@ import java.util.Map;
|
||||
|
||||
/**
|
||||
* 说明: json格式转换
|
||||
* 创建日期: 2016年8月16日
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
public class JSONUtil {
|
||||
|
||||
@@ -5,7 +5,6 @@ import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
/**
|
||||
* 创建时间: 2017/10/11 14:34
|
||||
* 作者: xiangwb
|
||||
* 说明:
|
||||
*/
|
||||
|
||||
@@ -12,8 +12,6 @@ import java.security.MessageDigest;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-demo
|
||||
* 创建时间: 2017/11/16 17:46
|
||||
* 作者: xiangwb
|
||||
* 说明: 快递鸟工具类
|
||||
* 文档: http://www.kdniao.com/documents
|
||||
|
||||
@@ -7,7 +7,6 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 创建时间: 2017/10/18 8:55
|
||||
* 作者: xiangwb
|
||||
* 说明: 列表分页工具类
|
||||
*/
|
||||
|
||||
@@ -1,62 +1,64 @@
|
||||
package com.xwbing.util;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* 说明:密码工具类
|
||||
* 创建日期: 2016年11月29日 上午10:28:36
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
public class PassWordUtil {
|
||||
/**
|
||||
* 初始默认密码长度
|
||||
*/
|
||||
public static final int PWD_LENGTH = 8;
|
||||
/**
|
||||
* 密码盐长度
|
||||
*/
|
||||
public static final int SALT_SIZE = 10;
|
||||
/**
|
||||
* hash
|
||||
*/
|
||||
public static int HASH_INTERATIONS = 1024;
|
||||
public static void main(String[] args) {
|
||||
getUserSecret("123456", "123456");
|
||||
}
|
||||
/**
|
||||
* 传入未加密密码,如果为空,随机生成, 传入盐值, 如果为空,随机生成。 返回密码,盐值,和加密后的密码
|
||||
*
|
||||
* @param password
|
||||
* @return
|
||||
*/
|
||||
public static String[] getUserSecret(String password, String pwdSalt) {
|
||||
String[] str = new String[3];
|
||||
if (StringUtils.isEmpty(password))
|
||||
password = RadomUtil.buildRandom(PWD_LENGTH);
|
||||
// 密码盐值
|
||||
byte[] salt;
|
||||
// 密码盐值 如果是为空,那么随机获取;不为空,解析pwdSalt
|
||||
if (StringUtils.isEmpty(pwdSalt)) {
|
||||
salt = Digests.generateSalt(SALT_SIZE);
|
||||
} else
|
||||
salt = EncodeUtils.hexDecode(pwdSalt);
|
||||
// 密码加密
|
||||
byte[] hashPassword = Digests.sha1(password.getBytes(), salt,
|
||||
HASH_INTERATIONS);
|
||||
str[0] = password;
|
||||
str[1] = EncodeUtils.hexEncode(salt);
|
||||
str[2] = EncodeUtils.hexEncode(hashPassword);
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成uuid
|
||||
* @return
|
||||
*/
|
||||
public static String createId(){
|
||||
UUID uuid=UUID.randomUUID();
|
||||
return uuid.toString().replace("-","");
|
||||
}
|
||||
/**
|
||||
* 初始默认密码长度
|
||||
*/
|
||||
public static final int PWD_LENGTH = 8;
|
||||
/**
|
||||
* 密码盐长度
|
||||
*/
|
||||
public static final int SALT_SIZE = 10;
|
||||
/**
|
||||
* hash
|
||||
*/
|
||||
public static int HASH_INTERATIONS = 1024;
|
||||
|
||||
public static void main(String[] args) {
|
||||
getUserSecret("123456", "123456");
|
||||
}
|
||||
|
||||
/**
|
||||
* 传入未加密密码,如果为空,随机生成, 传入盐值, 如果为空,随机生成。 返回密码,盐值,和加密后的密码
|
||||
*
|
||||
* @param password
|
||||
* @return
|
||||
*/
|
||||
public static String[] getUserSecret(String password, String pwdSalt) {
|
||||
String[] str = new String[3];
|
||||
if (StringUtils.isEmpty(password))
|
||||
password = RadomUtil.buildRandom(PWD_LENGTH);
|
||||
// 密码盐值
|
||||
byte[] salt;
|
||||
// 密码盐值 如果是为空,那么随机获取;不为空,解析pwdSalt
|
||||
if (StringUtils.isEmpty(pwdSalt)) {
|
||||
salt = Digests.generateSalt(SALT_SIZE);
|
||||
} else
|
||||
salt = EncodeUtils.hexDecode(pwdSalt);
|
||||
// 密码加密
|
||||
byte[] hashPassword = Digests.sha1(password.getBytes(), salt,
|
||||
HASH_INTERATIONS);
|
||||
str[0] = password;
|
||||
str[1] = EncodeUtils.hexEncode(salt);
|
||||
str[2] = EncodeUtils.hexEncode(hashPassword);
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成uuid
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String createId() {
|
||||
UUID uuid = UUID.randomUUID();
|
||||
return uuid.toString().replace("-", "");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,8 +13,6 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-demo
|
||||
* 创建时间: 2017/11/17 11:43
|
||||
* 作者: xiangwb
|
||||
* 说明: PingUtil
|
||||
*/
|
||||
|
||||
@@ -25,8 +25,6 @@ import java.util.Hashtable;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-demo
|
||||
* 创建时间: 2017/11/17 11:43
|
||||
* 作者: xiangwb
|
||||
* 说明: 二维码工具类
|
||||
*/
|
||||
@@ -282,7 +280,7 @@ public class QRCodeUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args){
|
||||
public static void main(String[] args) {
|
||||
// String tomcatHome = System.getProperty("catalina.home");
|
||||
// String name="QRcode";
|
||||
// File output=new File(tomcatHome+File.separator+"file"+File.separator+name+".png");
|
||||
|
||||
@@ -23,10 +23,8 @@ import java.security.spec.RSAPrivateKeySpec;
|
||||
import java.security.spec.X509EncodedKeySpec;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-demo
|
||||
* 创建时间: 2017/11/20 16:26
|
||||
* 作者: xiangwb
|
||||
* 说明:
|
||||
* 说明: RSAUtil
|
||||
*/
|
||||
public class RSAUtil {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(RSAUtil.class);
|
||||
@@ -230,7 +228,7 @@ public class RSAUtil {
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
public static String decrypt(String data){
|
||||
public static String decrypt(String data) {
|
||||
return decrypt(loadPrivateKey(), data);
|
||||
}
|
||||
|
||||
@@ -240,13 +238,13 @@ public class RSAUtil {
|
||||
System.out.println(de);
|
||||
}
|
||||
|
||||
private static String testJiami(){
|
||||
private static String testJiami() {
|
||||
String plainText = encrypt(loadPublicKey(), "123456");
|
||||
System.out.println("加密结果:" + plainText);
|
||||
return plainText;
|
||||
}
|
||||
|
||||
private static String testJiemi(String str){
|
||||
private static String testJiemi(String str) {
|
||||
String plainText = decrypt(loadPrivateKey(), str);
|
||||
System.out.println("解密结果:" + plainText);
|
||||
return plainText;
|
||||
|
||||
@@ -6,19 +6,16 @@ import java.util.Random;
|
||||
|
||||
/**
|
||||
* 说明:生成随机码
|
||||
* 创建日期: 2016年11月29日 上午10:28:21
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
public class RadomUtil {
|
||||
|
||||
public static String str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
|
||||
public static String buildRandom(int length) {
|
||||
if (length < 1)
|
||||
throw new UtilException("参数异常!!!");
|
||||
Random random = new Random();
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < length; i++) {
|
||||
String str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
int number = random.nextInt(str.length());
|
||||
sb.append(str.charAt(number));
|
||||
}
|
||||
@@ -29,6 +26,4 @@ public class RadomUtil {
|
||||
while (true)
|
||||
System.out.println(buildRandom(8));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -3,9 +3,9 @@ package com.xwbing.util;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 说明:返回消息封装类
|
||||
* 创建日期: 2017年3月3日 上午11:43:13
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
@Data
|
||||
|
||||
@@ -11,10 +11,8 @@ import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
/**
|
||||
* 项目名称: boot-module-demo
|
||||
* 创建时间: 2017/11/17 14:24
|
||||
* 作者: xiangwb
|
||||
* 说明:
|
||||
* 说明: ZipUtil
|
||||
*/
|
||||
public class ZipUtil {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ZipUtil.class);
|
||||
|
||||
Reference in New Issue
Block a user