修改代码字符编码
This commit is contained in:
@@ -24,7 +24,7 @@ public class BaseConfiguration extends ConfigurationSupport {
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否在开发环境中运行
|
||||
* 是否在开发环境中运行
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@@ -33,7 +33,7 @@ public class BaseConfiguration extends ConfigurationSupport {
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否在测试环境中运行
|
||||
* 是否在测试环境中运行
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@@ -42,7 +42,7 @@ public class BaseConfiguration extends ConfigurationSupport {
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否在生产环境中运行
|
||||
* 是否在生产环境中运行
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@@ -51,7 +51,7 @@ public class BaseConfiguration extends ConfigurationSupport {
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否禁用cache,默认为true
|
||||
* 判断是否禁用cache,默认为true
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@@ -60,7 +60,7 @@ public class BaseConfiguration extends ConfigurationSupport {
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否禁用本地缓存cache,默认为true
|
||||
* 判断是否禁用本地缓存cache,默认为true
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
@@ -17,7 +17,7 @@ public class AnalyticsUtil {
|
||||
private static final Logger LOG = Logger.getLogger(AnalyticsUtil.class.getPackage().getName());
|
||||
|
||||
/**
|
||||
* 增加跟踪信息数据
|
||||
* 增加跟踪信息数据
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
@@ -40,7 +40,7 @@ public class AnalyticsUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 在通过Apache,Squid等反向代理软件时获得用户的真实IP.
|
||||
* 在通过Apache,Squid等反向代理软件时获得用户的真实IP.
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
@@ -71,7 +71,7 @@ public class AnalyticsUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是需要被忽略的IP
|
||||
* 是否是需要被忽略的IP
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@@ -84,7 +84,7 @@ public class AnalyticsUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到本地机器名
|
||||
* 得到本地机器名
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@@ -101,7 +101,7 @@ public class AnalyticsUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取参数对应的Cookie值
|
||||
* 获取参数对应的Cookie值
|
||||
*
|
||||
* @param httpRequest
|
||||
* @param parameter
|
||||
@@ -144,7 +144,7 @@ public class AnalyticsUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到编码过的URI 把URI从iso-8859-1转换成UTF-8
|
||||
* 得到编码过的URI 把URI从iso-8859-1转换成UTF-8
|
||||
*
|
||||
* @param uri
|
||||
* @return
|
||||
|
||||
@@ -4,7 +4,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Òì²½ÔËÐÐÏß³Ì
|
||||
* 异步运行线程
|
||||
*
|
||||
* @author xiaoyu
|
||||
*
|
||||
|
||||
@@ -14,9 +14,9 @@ public class BeanUtils {
|
||||
private final static Logger LOGGER = LoggerFactory.getLogger(BeanUtils.class);
|
||||
|
||||
/**
|
||||
* 复制 source 属性 到 target
|
||||
* 复制 source 属性 到 target
|
||||
*
|
||||
* 数据类型 参数名 不同 忽略
|
||||
* 数据类型 参数名 不同 忽略
|
||||
*
|
||||
* @param model
|
||||
* @return
|
||||
@@ -52,7 +52,7 @@ public class BeanUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* 复制JSON对象属性到target
|
||||
* 复制JSON对象属性到target
|
||||
*
|
||||
* @param source
|
||||
* @param target
|
||||
|
||||
@@ -4,19 +4,19 @@ import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
|
||||
public class BigNumber {
|
||||
//默认除法运算精度,即保留小数点多少位
|
||||
//默认除法运算精度,即保留小数点多少位
|
||||
private static final int DEFAULT_DIV_SCALE = 10;
|
||||
|
||||
//这个类不能实例化
|
||||
//这个类不能实例化
|
||||
private BigNumber() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 提供精确的加法运算。
|
||||
* 提供精确的加法运算。
|
||||
*
|
||||
* @param v1 被加数
|
||||
* @param v2 加数
|
||||
* @return 两个参数的和
|
||||
* @param v1 被加数
|
||||
* @param v2 加数
|
||||
* @return 两个参数的和
|
||||
*/
|
||||
public static double add(double v1, double v2) {
|
||||
BigDecimal b1 = new BigDecimal(Double.toString(v1));
|
||||
@@ -25,11 +25,11 @@ public class BigNumber {
|
||||
}
|
||||
|
||||
/**
|
||||
* 提供精确的减法运算。
|
||||
* 提供精确的减法运算。
|
||||
*
|
||||
* @param v1 被减数
|
||||
* @param v2 减数
|
||||
* @return 两个参数的差
|
||||
* @param v1 被减数
|
||||
* @param v2 减数
|
||||
* @return 两个参数的差
|
||||
*/
|
||||
public static double sub(double v1, double v2) {
|
||||
BigDecimal b1 = new BigDecimal(Double.toString(v1));
|
||||
@@ -38,11 +38,11 @@ public class BigNumber {
|
||||
}
|
||||
|
||||
/**
|
||||
* 提供精确的乘法运算。
|
||||
* 提供精确的乘法运算。
|
||||
*
|
||||
* @param v1 被乘数
|
||||
* @param v2 乘数
|
||||
* @return 两个参数的积
|
||||
* @param v1 被乘数
|
||||
* @param v2 乘数
|
||||
* @return 两个参数的积
|
||||
*/
|
||||
public static double mul(double v1, double v2) {
|
||||
BigDecimal b1 = new BigDecimal(Double.toString(v1));
|
||||
@@ -51,29 +51,29 @@ public class BigNumber {
|
||||
}
|
||||
|
||||
/**
|
||||
* 提供(相对)精确的除法运算,当发生除不尽的情况时,精确到
|
||||
* 小数点以后多少位,以后的数字四舍五入。
|
||||
* 提供(相对)精确的除法运算,当发生除不尽的情况时,精确到
|
||||
* 小数点以后多少位,以后的数字四舍五入。
|
||||
*
|
||||
* @param v1 被除数
|
||||
* @param v2 除数
|
||||
* @return 两个参数的商
|
||||
* @param v1 被除数
|
||||
* @param v2 除数
|
||||
* @return 两个参数的商
|
||||
*/
|
||||
public static double div(double v1, double v2) {
|
||||
return div(v1, v2, DEFAULT_DIV_SCALE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 提供(相对)精确的除法运算。当发生除不尽的情况时,由scale参数指
|
||||
* 定精度,以后的数字四舍五入。
|
||||
* 提供(相对)精确的除法运算。当发生除不尽的情况时,由scale参数指
|
||||
* 定精度,以后的数字四舍五入。
|
||||
*
|
||||
* @param v1 被除数
|
||||
* @param v2 除数
|
||||
* @param scale 表示需要精确到小数点以后几位。
|
||||
* @return 两个参数的商
|
||||
* @param v1 被除数
|
||||
* @param v2 除数
|
||||
* @param scale 表示需要精确到小数点以后几位。
|
||||
* @return 两个参数的商
|
||||
*/
|
||||
public static double div(double v1, double v2, int scale) {
|
||||
if (scale < 0) {
|
||||
System.err.println("除法精度必须大于0!");
|
||||
System.err.println("除法精度必须大于0!");
|
||||
return 0;
|
||||
}
|
||||
BigDecimal b1 = new BigDecimal(Double.toString(v1));
|
||||
@@ -82,29 +82,29 @@ public class BigNumber {
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算Factorial阶乘!
|
||||
* 计算Factorial阶乘!
|
||||
*
|
||||
* @param n 任意大于等于0的int
|
||||
* @return n!的值
|
||||
* @param n 任意大于等于0的int
|
||||
* @return n!的值
|
||||
*/
|
||||
public static BigInteger getFactorial(int n) {
|
||||
if (n < 0) {
|
||||
System.err.println("n必须大于等于0!");
|
||||
System.err.println("n必须大于等于0!");
|
||||
return new BigInteger("-1");
|
||||
} else if (n == 0) {
|
||||
return new BigInteger("0");
|
||||
}
|
||||
//将数组换成字符串后构造BigInteger
|
||||
//将数组换成字符串后构造BigInteger
|
||||
BigInteger result = new BigInteger("1");
|
||||
for (; n > 0; n--) {
|
||||
//将数字n转换成字符串后,再构造一个BigInteger对象,与现有结果做乘法
|
||||
//将数字n转换成字符串后,再构造一个BigInteger对象,与现有结果做乘法
|
||||
result = result.multiply(new BigInteger(new Integer(n).toString()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// 如果我们编译运行下面这个程序会看到什么?
|
||||
// 如果我们编译运行下面这个程序会看到什么?
|
||||
System.out.println(0.05 + 0.01);
|
||||
System.out.println(1.0 - 0.42);
|
||||
System.out.println(4.015 * 100);
|
||||
@@ -113,22 +113,22 @@ public class BigNumber {
|
||||
// 0.5800000000000001
|
||||
// 401.49999999999994
|
||||
// 1.2329999999999999
|
||||
//计算阶乘,可以将n设得更大
|
||||
//计算阶乘,可以将n设得更大
|
||||
int n = 30;
|
||||
System.out.println("计算n的阶乘" + n + "! = " + BigNumber.getFactorial(n));
|
||||
//用double构造BigDecimal
|
||||
System.out.println("计算n的阶乘" + n + "! = " + BigNumber.getFactorial(n));
|
||||
//用double构造BigDecimal
|
||||
BigDecimal bd1 = new BigDecimal(0.1);
|
||||
System.out.println("(bd1 = new BigDecimal(0.1)) = " + bd1.toString());
|
||||
//用String构造BigDecimal
|
||||
//用String构造BigDecimal
|
||||
BigDecimal bd2 = new BigDecimal("0.1");
|
||||
System.out.println("(bd2 = new BigDecimal(\"0.1\")) = "
|
||||
+ bd2.toString());
|
||||
BigDecimal bd3 = new BigDecimal("0.10");
|
||||
//equals方法比较两个BigDecimal对象是否相等,相等返回true,不等返回false
|
||||
//equals方法比较两个BigDecimal对象是否相等,相等返回true,不等返回false
|
||||
System.out.println("bd2.equals(bd3) = " + bd2.equals(bd3));//false
|
||||
//compareTo方法比较两个BigDecimal对象的大小,相等返回0,小于返回-1,大于返回1。
|
||||
//compareTo方法比较两个BigDecimal对象的大小,相等返回0,小于返回-1,大于返回1。
|
||||
System.out.println("bd2.compareTo(bd3) = " + bd2.compareTo(bd3));//0
|
||||
//进行精确计算
|
||||
//进行精确计算
|
||||
System.out.println("0.05 + 0.01 = " + BigNumber.add(0.05, 0.01));
|
||||
System.out.println("1.0 - 0.42 = " + BigNumber.sub(1.0, 0.42));
|
||||
System.out.println("4.015 * 100 =" + BigNumber.mul(4.015, 100));
|
||||
|
||||
+26
-26
@@ -4,20 +4,20 @@ import java.text.DecimalFormat;
|
||||
|
||||
/**
|
||||
*
|
||||
* 货币转换
|
||||
* 货币转换
|
||||
*
|
||||
*/
|
||||
public class CurrencyConverter {
|
||||
|
||||
/** 大写数字 */
|
||||
private static final String[] NUMBERS = { "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" };
|
||||
/** 整数部分的单位 */
|
||||
private static final String[] IUNIT = { "元", "拾", "佰", "仟", "万", "拾", "佰", "仟", "亿", "拾", "佰", "仟", "万", "拾", "佰", "仟" };
|
||||
/** 小数部分的单位 */
|
||||
private static final String[] DUNIT = { "角", "分", "厘" };
|
||||
/** 大写数字 */
|
||||
private static final String[] NUMBERS = { "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" };
|
||||
/** 整数部分的单位 */
|
||||
private static final String[] IUNIT = { "元", "拾", "佰", "仟", "万", "拾", "佰", "仟", "亿", "拾", "佰", "仟", "万", "拾", "佰", "仟" };
|
||||
/** 小数部分的单位 */
|
||||
private static final String[] DUNIT = { "角", "分", "厘" };
|
||||
|
||||
/**
|
||||
* 得到大写金额。
|
||||
* 得到大写金额。
|
||||
*/
|
||||
public static String toChinese(String str) {
|
||||
str = str.replaceAll(",", "");
|
||||
@@ -40,18 +40,18 @@ public class CurrencyConverter {
|
||||
}
|
||||
}
|
||||
if (integerStr.length() > IUNIT.length) {
|
||||
System.out.println(str + ":超出处理能力");
|
||||
System.out.println(str + ":超出处理能力");
|
||||
return str;
|
||||
}
|
||||
|
||||
int[] integers = toArray(integerStr);// 整数部分数字
|
||||
boolean isMust5 = isMust5(integerStr);// 设置万单位
|
||||
int[] decimals = toArray(decimalStr);// 小数部分数字
|
||||
int[] integers = toArray(integerStr);// 整数部分数字
|
||||
boolean isMust5 = isMust5(integerStr);// 设置万单位
|
||||
int[] decimals = toArray(decimalStr);// 小数部分数字
|
||||
return getChineseInteger(integers, isMust5) + getChineseDecimal(decimals);
|
||||
}
|
||||
|
||||
/**
|
||||
* 整数部分和小数部分转换为数组,从高位至低位
|
||||
* 整数部分和小数部分转换为数组,从高位至低位
|
||||
*/
|
||||
private static int[] toArray(String number) {
|
||||
int[] array = new int[number.length()];
|
||||
@@ -62,25 +62,25 @@ public class CurrencyConverter {
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到中文金额的整数部分。
|
||||
* 得到中文金额的整数部分。
|
||||
*/
|
||||
private static String getChineseInteger(int[] integers, boolean isMust5) {
|
||||
StringBuffer chineseInteger = new StringBuffer("");
|
||||
int length = integers.length;
|
||||
for (int i = 0; i < length; i++) {
|
||||
// 0出现在关键位置:1234(万)5678(亿)9012(万)3456(元)
|
||||
// 特殊情况:10(拾元、壹拾元、壹拾万元、拾万元)
|
||||
// 0出现在关键位置:1234(万)5678(亿)9012(万)3456(元)
|
||||
// 特殊情况:10(拾元、壹拾元、壹拾万元、拾万元)
|
||||
String key = "";
|
||||
if (integers[i] == 0) {
|
||||
if ((length - i) == 13)// 万(亿)(必填)
|
||||
if ((length - i) == 13)// 万(亿)(必填)
|
||||
key = IUNIT[4];
|
||||
else if ((length - i) == 9)// 亿(必填)
|
||||
else if ((length - i) == 9)// 亿(必填)
|
||||
key = IUNIT[8];
|
||||
else if ((length - i) == 5 && isMust5)// 万(不必填)
|
||||
else if ((length - i) == 5 && isMust5)// 万(不必填)
|
||||
key = IUNIT[4];
|
||||
else if ((length - i) == 1)// 元(必填)
|
||||
else if ((length - i) == 1)// 元(必填)
|
||||
key = IUNIT[0];
|
||||
// 0遇非0时补零,不包含最后一位
|
||||
// 0遇非0时补零,不包含最后一位
|
||||
if ((length - i) > 1 && integers[i + 1] != 0)
|
||||
key += NUMBERS[0];
|
||||
}
|
||||
@@ -90,12 +90,12 @@ public class CurrencyConverter {
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到中文金额的小数部分。
|
||||
* 得到中文金额的小数部分。
|
||||
*/
|
||||
private static String getChineseDecimal(int[] decimals) {
|
||||
StringBuffer chineseDecimal = new StringBuffer("");
|
||||
for (int i = 0; i < decimals.length; i++) {
|
||||
// 舍去3位小数之后的
|
||||
// 舍去3位小数之后的
|
||||
if (i == 3)
|
||||
break;
|
||||
chineseDecimal.append(decimals[i] == 0 ? "" : (NUMBERS[decimals[i]] + DUNIT[i]));
|
||||
@@ -104,14 +104,14 @@ public class CurrencyConverter {
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断第5位数字的单位"万"是否应加。
|
||||
* 判断第5位数字的单位"万"是否应加。
|
||||
*/
|
||||
private static boolean isMust5(String integerStr) {
|
||||
int length = integerStr.length();
|
||||
if (length > 4) {
|
||||
String subInteger = "";
|
||||
if (length > 8) {
|
||||
// 取得从低位数,第5到第8位的字串
|
||||
// 取得从低位数,第5到第8位的字串
|
||||
subInteger = integerStr.substring(length - 8, length - 4);
|
||||
} else {
|
||||
subInteger = integerStr.substring(0, length - 4);
|
||||
@@ -123,7 +123,7 @@ public class CurrencyConverter {
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化数字为千分位显示
|
||||
* 格式化数字为千分位显示
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
@@ -45,18 +45,18 @@ import org.slf4j.LoggerFactory;
|
||||
import org.sothis.core.util.CollectionUtils;
|
||||
|
||||
public class DataUtil {
|
||||
public static Pattern cellPhonePattern = Pattern.compile("^(1[23456789][0-9]{1})(-)?([0-9]{8})$");//判断是否手机号码
|
||||
public static Pattern cellPhonePattern = Pattern.compile("^(1[23456789][0-9]{1})(-)?([0-9]{8})$");//判断是否手机号码
|
||||
private final static Logger LOGGER = LoggerFactory.getLogger(DataUtil.class);
|
||||
public static Pattern LINK = Pattern.compile("[a-zA-z]+://[a-zA-Z0-9./%?=&-]*"); // 网址
|
||||
public static Pattern LINK = Pattern.compile("[a-zA-z]+://[a-zA-Z0-9./%?=&-]*"); // 网址
|
||||
// public static Pattern MOBILE_344 =
|
||||
// Pattern.compile("(\\d{3}-\\d{4}-\\d{4})");
|
||||
public static Pattern NUM_SERIES = Pattern.compile("(?:\\d[\\s-]*){7}");// ;连续数字
|
||||
public static Pattern URL_SUFFIX = Pattern.compile("[a-zA-Z0-9.]*\\.((?:com)|(?:COM)|(?:cn)|(?:CN)|(?:net)|(?:NET))"); // 后缀
|
||||
public static Pattern IMG = Pattern.compile("<img.*src=(.*?)[^>]*?>"); // 图片链接地址
|
||||
public static Pattern OUT_TAG = Pattern.compile("</?[a-zA-Z0-9]+:[a-zA-Z0-9]+[^>]*>"); // 外部标签
|
||||
public static final Pattern WORDS = Pattern.compile(".*[a-zA-Z].*");//是否包含字母
|
||||
public static Pattern NUM_SERIES = Pattern.compile("(?:\\d[\\s-]*){7}");// ;连续数字
|
||||
public static Pattern URL_SUFFIX = Pattern.compile("[a-zA-Z0-9.]*\\.((?:com)|(?:COM)|(?:cn)|(?:CN)|(?:net)|(?:NET))"); // 后缀
|
||||
public static Pattern IMG = Pattern.compile("<img.*src=(.*?)[^>]*?>"); // 图片链接地址
|
||||
public static Pattern OUT_TAG = Pattern.compile("</?[a-zA-Z0-9]+:[a-zA-Z0-9]+[^>]*>"); // 外部标签
|
||||
public static final Pattern WORDS = Pattern.compile(".*[a-zA-Z].*");//是否包含字母
|
||||
public static final Pattern NO_WORDS = Pattern.compile(".*[^a-zA-Z].*");
|
||||
public static String SPACIAL_PATTERN = "[`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?]";
|
||||
public static String SPACIAL_PATTERN = "[`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?]";
|
||||
public static final HanyuPinyinOutputFormat pinyinFormat = new HanyuPinyinOutputFormat();
|
||||
public static final Pattern PRICE_PATT = Pattern.compile("(\\d+)");
|
||||
public static String replaceAll(String original, String with, Pattern... pattern) {
|
||||
@@ -71,11 +71,11 @@ public class DataUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理指定字符串中的特殊字符
|
||||
* 清理指定字符串中的特殊字符
|
||||
*
|
||||
* 目前清理特殊字符有:手机、电话、QQ、邮箱、MSN
|
||||
* 目前清理特殊字符有:手机、电话、QQ、邮箱、MSN
|
||||
*
|
||||
* 例: 联系电话:13569335693 清理后: 联系电话:******5693
|
||||
* 例: 联系电话:13569335693 清理后: 联系电话:******5693
|
||||
*
|
||||
* @author liupei
|
||||
*/
|
||||
@@ -101,18 +101,18 @@ public class DataUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 截取字符串
|
||||
* 截取字符串
|
||||
*
|
||||
* 若原始字符串的长度小于最大截取长度,则直接返回原始字符串
|
||||
* 若原始字符串的长度小于最大截取长度,则直接返回原始字符串
|
||||
*
|
||||
* @param targetString
|
||||
* 原始字符串
|
||||
* 原始字符串
|
||||
* @param targetLength
|
||||
* 最大长度
|
||||
* 最大长度
|
||||
* @param tailLength
|
||||
* 尾巴长度
|
||||
* 尾巴长度
|
||||
* @param tailString
|
||||
* 结尾字符串
|
||||
* 结尾字符串
|
||||
* @return
|
||||
*/
|
||||
public static String cutString(String targetString, int targetLength, int tailLength, String tailString) {
|
||||
@@ -127,12 +127,12 @@ public class DataUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 按字节截取字符串
|
||||
* 按字节截取字符串
|
||||
*
|
||||
* @param targetString
|
||||
* 原始字符串
|
||||
* 原始字符串
|
||||
* @param length
|
||||
* 截取长度
|
||||
* 截取长度
|
||||
* @return
|
||||
* @throws UnsupportedEncodingException
|
||||
*/
|
||||
@@ -145,14 +145,14 @@ public class DataUtil {
|
||||
if (bytes.length <= length) {
|
||||
return targetString;
|
||||
} else {
|
||||
int n = 0; // 表示当前的字节数
|
||||
int i = 2; // 要截取的字节数,从第3个字节开始
|
||||
int n = 0; // 表示当前的字节数
|
||||
int i = 2; // 要截取的字节数,从第3个字节开始
|
||||
for (; i < bytes.length && n < length; i++) {
|
||||
// 奇数位置,如3、5、7等,为UCS2编码中两个字节的第二个字节
|
||||
// 奇数位置,如3、5、7等,为UCS2编码中两个字节的第二个字节
|
||||
if (i % 2 == 1) {
|
||||
n++; // 在UCS2第二个字节时n加1
|
||||
n++; // 在UCS2第二个字节时n加1
|
||||
} else {
|
||||
// 当UCS2编码的第一个字节不等于0时,该UCS2字符为汉字,一个汉字算两个字节
|
||||
// 当UCS2编码的第一个字节不等于0时,该UCS2字符为汉字,一个汉字算两个字节
|
||||
if (bytes[i] != 0) {
|
||||
n++;
|
||||
}
|
||||
@@ -160,12 +160,12 @@ public class DataUtil {
|
||||
}
|
||||
|
||||
if (i % 2 == 1) {
|
||||
// 如果i为奇数时,处理成偶数
|
||||
// 如果i为奇数时,处理成偶数
|
||||
if (bytes[i - 1] != 0) {
|
||||
// 该UCS2字符是汉字时,去掉这个截一半的汉字
|
||||
// 该UCS2字符是汉字时,去掉这个截一半的汉字
|
||||
i = i - 1;
|
||||
} else {
|
||||
// 该UCS2字符是字母或数字,则保留该字符
|
||||
// 该UCS2字符是字母或数字,则保留该字符
|
||||
i = i + 1;
|
||||
}
|
||||
}
|
||||
@@ -175,9 +175,9 @@ public class DataUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化均价
|
||||
* 格式化均价
|
||||
*
|
||||
* 将个位和十位直接变为0
|
||||
* 将个位和十位直接变为0
|
||||
*
|
||||
* @param avgPirce
|
||||
* @return
|
||||
@@ -191,7 +191,7 @@ public class DataUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 全角转半角
|
||||
* 全角转半角
|
||||
*
|
||||
* @param input
|
||||
* @return
|
||||
@@ -212,7 +212,7 @@ public class DataUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断文本中的链接是否是fangjia,如果不是就删除
|
||||
* 判断文本中的链接是否是fangjia,如果不是就删除
|
||||
*
|
||||
* @param htmlDes
|
||||
* @return
|
||||
@@ -271,7 +271,7 @@ public class DataUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 加密图片url
|
||||
* 加密图片url
|
||||
*
|
||||
* @param u
|
||||
* @param s
|
||||
@@ -290,7 +290,7 @@ public class DataUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 把字符串以16进制数值显示出来
|
||||
* 把字符串以16进制数值显示出来
|
||||
*
|
||||
* @param data
|
||||
* @return
|
||||
@@ -305,7 +305,7 @@ public class DataUtil {
|
||||
return ret.toString();
|
||||
}
|
||||
|
||||
// 字节码转换成16进制字符串
|
||||
// 字节码转换成16进制字符串
|
||||
public static String byte2hex(byte bytes[]) {
|
||||
StringBuffer retString = new StringBuffer();
|
||||
for (int i = 0; i < bytes.length; ++i) {
|
||||
@@ -314,7 +314,7 @@ public class DataUtil {
|
||||
return retString.toString();
|
||||
}
|
||||
|
||||
// 将16进制字符串转换成字节码
|
||||
// 将16进制字符串转换成字节码
|
||||
public static byte[] hex2byte(String hex) {
|
||||
byte[] bts = new byte[hex.length() / 2];
|
||||
for (int i = 0; i < bts.length; i++) {
|
||||
@@ -324,7 +324,7 @@ public class DataUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否是标准的手机号码
|
||||
* 判断是否是标准的手机号码
|
||||
*
|
||||
* @param phoneNum
|
||||
* @return
|
||||
@@ -386,7 +386,7 @@ public class DataUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 去掉str中的html标记
|
||||
* 去掉str中的html标记
|
||||
*
|
||||
* @param str
|
||||
* @return
|
||||
@@ -400,10 +400,10 @@ public class DataUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 去除特殊字符串
|
||||
* 去除特殊字符串
|
||||
*
|
||||
* <p>
|
||||
* 特殊字符串定义:html,&*;,\[a-z]
|
||||
* 特殊字符串定义:html,&*;,\[a-z]
|
||||
* </p>
|
||||
*
|
||||
* @param str
|
||||
@@ -421,7 +421,7 @@ public class DataUtil {
|
||||
public static Pattern nameTags = Pattern.compile("</?([^>]*)(\\s|$|>)");
|
||||
|
||||
/**
|
||||
* 去除html中不完整的标签
|
||||
* 去除html中不完整的标签
|
||||
*
|
||||
* @param html
|
||||
* @return
|
||||
@@ -503,10 +503,10 @@ public class DataUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 四舍五入
|
||||
* 四舍五入
|
||||
*
|
||||
* @param dSource
|
||||
* 浮点数
|
||||
* 浮点数
|
||||
* @return
|
||||
*/
|
||||
public static int getRound(double dSource) {
|
||||
@@ -534,7 +534,7 @@ public class DataUtil {
|
||||
return decimalFormat.parse(decimalFormat.format(n)).doubleValue();
|
||||
}
|
||||
|
||||
public static List<String> SENSITIVE_WORDS = Arrays.asList("上门服务", "小姐", "冰毒", "手枪", "疏通", "掏粪", "污水", "办证", "公务员", "汽狗");
|
||||
public static List<String> SENSITIVE_WORDS = Arrays.asList("上门服务", "小姐", "冰毒", "手枪", "疏通", "掏粪", "污水", "办证", "公务员", "汽狗");
|
||||
|
||||
public static List<String> getSensitiveWords() {
|
||||
return SENSITIVE_WORDS;
|
||||
@@ -591,7 +591,7 @@ public class DataUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 将集合反向排序
|
||||
* 将集合反向排序
|
||||
*
|
||||
* @param <V>
|
||||
* @param col
|
||||
@@ -609,12 +609,12 @@ public class DataUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据Value对Map进行排序
|
||||
* 根据Value对Map进行排序
|
||||
*
|
||||
* @param targetMap+
|
||||
* key:Object value:Number
|
||||
* @param asc
|
||||
* true:升序 false:降序
|
||||
* true:升序 false:降序
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@@ -672,7 +672,7 @@ public class DataUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取url的主域名
|
||||
* 获取url的主域名
|
||||
*
|
||||
* @param url
|
||||
* @return
|
||||
@@ -693,34 +693,34 @@ public class DataUtil {
|
||||
|
||||
switch (Integer.parseInt(ca)) {
|
||||
case 0:
|
||||
ret.append("零");
|
||||
ret.append("零");
|
||||
break;
|
||||
case 1:
|
||||
ret.append("壹");
|
||||
ret.append("壹");
|
||||
break;
|
||||
case 2:
|
||||
ret.append("贰");
|
||||
ret.append("贰");
|
||||
break;
|
||||
case 3:
|
||||
ret.append("叁");
|
||||
ret.append("叁");
|
||||
break;
|
||||
case 4:
|
||||
ret.append("肆");
|
||||
ret.append("肆");
|
||||
break;
|
||||
case 5:
|
||||
ret.append("伍");
|
||||
ret.append("伍");
|
||||
break;
|
||||
case 6:
|
||||
ret.append("陆");
|
||||
ret.append("陆");
|
||||
break;
|
||||
case 7:
|
||||
ret.append("柒");
|
||||
ret.append("柒");
|
||||
break;
|
||||
case 8:
|
||||
ret.append("捌");
|
||||
ret.append("捌");
|
||||
break;
|
||||
case 9:
|
||||
ret.append("玖");
|
||||
ret.append("玖");
|
||||
break;
|
||||
default:
|
||||
ret.append(ca);
|
||||
@@ -747,31 +747,31 @@ public class DataUtil {
|
||||
ret.append("0");
|
||||
break;
|
||||
case 1:
|
||||
ret.append("一");
|
||||
ret.append("一");
|
||||
break;
|
||||
case 2:
|
||||
ret.append("二");
|
||||
ret.append("二");
|
||||
break;
|
||||
case 3:
|
||||
ret.append("三");
|
||||
ret.append("三");
|
||||
break;
|
||||
case 4:
|
||||
ret.append("四");
|
||||
ret.append("四");
|
||||
break;
|
||||
case 5:
|
||||
ret.append("五");
|
||||
ret.append("五");
|
||||
break;
|
||||
case 6:
|
||||
ret.append("六");
|
||||
ret.append("六");
|
||||
break;
|
||||
case 7:
|
||||
ret.append("七");
|
||||
ret.append("七");
|
||||
break;
|
||||
case 8:
|
||||
ret.append("八");
|
||||
ret.append("八");
|
||||
break;
|
||||
case 9:
|
||||
ret.append("九");
|
||||
ret.append("九");
|
||||
break;
|
||||
default:
|
||||
ret.append(ca);
|
||||
@@ -789,25 +789,25 @@ public class DataUtil {
|
||||
for (int i = 0; i < charArray.length; i++) {
|
||||
String ca = String.valueOf(charArray[i]);
|
||||
|
||||
if (ca.equals("零")) {
|
||||
if (ca.equals("零")) {
|
||||
ret.append("0");
|
||||
} else if (ca.equals("壹")) {
|
||||
} else if (ca.equals("壹")) {
|
||||
ret.append("1");
|
||||
} else if (ca.equals("贰")) {
|
||||
} else if (ca.equals("贰")) {
|
||||
ret.append("2");
|
||||
} else if (ca.equals("叁")) {
|
||||
} else if (ca.equals("叁")) {
|
||||
ret.append("3");
|
||||
} else if (ca.equals("肆")) {
|
||||
} else if (ca.equals("肆")) {
|
||||
ret.append("4");
|
||||
} else if (ca.equals("伍")) {
|
||||
} else if (ca.equals("伍")) {
|
||||
ret.append("5");
|
||||
} else if (ca.equals("陆")) {
|
||||
} else if (ca.equals("陆")) {
|
||||
ret.append("6");
|
||||
} else if (ca.equals("柒")) {
|
||||
} else if (ca.equals("柒")) {
|
||||
ret.append("7");
|
||||
} else if (ca.equals("捌")) {
|
||||
} else if (ca.equals("捌")) {
|
||||
ret.append("8");
|
||||
} else if (ca.equals("玖")) {
|
||||
} else if (ca.equals("玖")) {
|
||||
ret.append("9");
|
||||
} else {
|
||||
ret.append(ca);
|
||||
@@ -823,27 +823,27 @@ public class DataUtil {
|
||||
for (int i = 0; i < charArray.length; i++) {
|
||||
String ca = String.valueOf(charArray[i]);
|
||||
|
||||
if (ca.equals("零")) {
|
||||
if (ca.equals("零")) {
|
||||
ret.append("0");
|
||||
} else if (ca.equals("一")) {
|
||||
} else if (ca.equals("一")) {
|
||||
ret.append("1");
|
||||
} else if (ca.equals("二")) {
|
||||
} else if (ca.equals("二")) {
|
||||
ret.append("2");
|
||||
} else if (ca.equals("三")) {
|
||||
} else if (ca.equals("三")) {
|
||||
ret.append("3");
|
||||
} else if (ca.equals("四")) {
|
||||
} else if (ca.equals("四")) {
|
||||
ret.append("4");
|
||||
} else if (ca.equals("五")) {
|
||||
} else if (ca.equals("五")) {
|
||||
ret.append("5");
|
||||
} else if (ca.equals("六")) {
|
||||
} else if (ca.equals("六")) {
|
||||
ret.append("6");
|
||||
} else if (ca.equals("七")) {
|
||||
} else if (ca.equals("七")) {
|
||||
ret.append("7");
|
||||
} else if (ca.equals("八")) {
|
||||
} else if (ca.equals("八")) {
|
||||
ret.append("8");
|
||||
} else if (ca.equals("九")) {
|
||||
} else if (ca.equals("九")) {
|
||||
ret.append("9");
|
||||
} else if (ca.equals("两")) {
|
||||
} else if (ca.equals("两")) {
|
||||
ret.append("2");
|
||||
} else {
|
||||
ret.append(ca);
|
||||
@@ -859,27 +859,27 @@ public class DataUtil {
|
||||
StringBuilder ret = new StringBuilder();
|
||||
for (int i = 0; i < charArray.length; i++) {
|
||||
String ca = String.valueOf(charArray[i]);
|
||||
if (ca.equals("零") || ca.equals("0")) {
|
||||
if (ca.equals("零") || ca.equals("0")) {
|
||||
ret.append("0");
|
||||
} else if (ca.equals("一")) {
|
||||
} else if (ca.equals("一")) {
|
||||
ret.append("1");
|
||||
} else if (ca.equals("二")) {
|
||||
} else if (ca.equals("二")) {
|
||||
ret.append("2");
|
||||
} else if (ca.equals("三")) {
|
||||
} else if (ca.equals("三")) {
|
||||
ret.append("3");
|
||||
} else if (ca.equals("四")) {
|
||||
} else if (ca.equals("四")) {
|
||||
ret.append("4");
|
||||
} else if (ca.equals("五")) {
|
||||
} else if (ca.equals("五")) {
|
||||
ret.append("5");
|
||||
} else if (ca.equals("六")) {
|
||||
} else if (ca.equals("六")) {
|
||||
ret.append("6");
|
||||
} else if (ca.equals("七")) {
|
||||
} else if (ca.equals("七")) {
|
||||
ret.append("7");
|
||||
} else if (ca.equals("八")) {
|
||||
} else if (ca.equals("八")) {
|
||||
ret.append("8");
|
||||
} else if (ca.equals("九")) {
|
||||
} else if (ca.equals("九")) {
|
||||
ret.append("9");
|
||||
} else if (ca.equals("两")) {
|
||||
} else if (ca.equals("两")) {
|
||||
ret.append("2");
|
||||
} else {
|
||||
ret.append(ca);
|
||||
@@ -938,7 +938,7 @@ public class DataUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否包含字母
|
||||
* 是否包含字母
|
||||
*
|
||||
* @param str
|
||||
* @return
|
||||
@@ -953,7 +953,7 @@ public class DataUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否包含非字母
|
||||
* 是否包含非字母
|
||||
*
|
||||
* @param str
|
||||
* @return
|
||||
@@ -967,7 +967,7 @@ public class DataUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 避免solr中的特殊符号
|
||||
* 避免solr中的特殊符号
|
||||
*
|
||||
* @param keyword
|
||||
* @return
|
||||
@@ -978,7 +978,7 @@ public class DataUtil {
|
||||
}
|
||||
keyword = encoding(keyword);
|
||||
keyword = keyword.replace("-", "");
|
||||
keyword = keyword.replace("-", "");
|
||||
keyword = keyword.replace("-", "");
|
||||
keyword = keyword.replace("\"", "");
|
||||
keyword = keyword.replaceAll(SPACIAL_PATTERN, "");
|
||||
keyword = keyword.replace("\\", " ");
|
||||
@@ -1010,7 +1010,7 @@ public class DataUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 汉语全拼
|
||||
* 汉语全拼
|
||||
*
|
||||
* @param keyword
|
||||
* @param separator
|
||||
@@ -1036,7 +1036,7 @@ public class DataUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 汉语简拼
|
||||
* 汉语简拼
|
||||
*
|
||||
* @param keyword
|
||||
* @return
|
||||
@@ -1058,20 +1058,20 @@ public class DataUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化板块,将"板块"字符串去掉
|
||||
* 格式化板块,将"板块"字符串去掉
|
||||
*
|
||||
* @param block
|
||||
* @return
|
||||
*/
|
||||
public static String formatBlock(String block) {
|
||||
if (StringUtils.isNotBlank(block)) {
|
||||
return block.replace("板块", "");
|
||||
return block.replace("板块", "");
|
||||
}
|
||||
return StringUtils.EMPTY;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字符串中汉字部分
|
||||
* 获取字符串中汉字部分
|
||||
*
|
||||
* @param s
|
||||
* @return
|
||||
@@ -1104,12 +1104,12 @@ public class DataUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查经纬度是否合法
|
||||
* 检查经纬度是否合法
|
||||
*
|
||||
* @param lat
|
||||
* 纬度为正负900000000000
|
||||
* 纬度为正负900000000000
|
||||
* @param lng
|
||||
* 经度为正负1800000000000
|
||||
* 经度为正负1800000000000
|
||||
* @return
|
||||
*/
|
||||
public static boolean verifyLatLng(Long lat, Long lng) {
|
||||
@@ -1121,12 +1121,12 @@ public class DataUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查经纬度是否合法
|
||||
* 检查经纬度是否合法
|
||||
*
|
||||
* @param lat
|
||||
* 纬度为正负90
|
||||
* 纬度为正负90
|
||||
* @param lng
|
||||
* 经度为正负180
|
||||
* 经度为正负180
|
||||
* @return
|
||||
*/
|
||||
public static boolean verifyLatLng(Double lat, Double lng) {
|
||||
@@ -1148,7 +1148,7 @@ public class DataUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 压缩
|
||||
* 压缩
|
||||
*
|
||||
* @param content
|
||||
* @return
|
||||
@@ -1175,7 +1175,7 @@ public class DataUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 解压
|
||||
* 解压
|
||||
*
|
||||
* @param content
|
||||
* @return
|
||||
@@ -1245,7 +1245,7 @@ public class DataUtil {
|
||||
}
|
||||
|
||||
public static String trim(String str) {
|
||||
return null == str ? null : str.replaceAll("^[\\s ]*|[\\s ]*$", "");
|
||||
return null == str ? null : str.replaceAll("^[\\s ]*|[\\s ]*$", "");
|
||||
}
|
||||
|
||||
public static boolean isNumeric(String str) {
|
||||
@@ -1268,7 +1268,7 @@ public class DataUtil {
|
||||
|
||||
|
||||
public static String stringFilter(String str) {
|
||||
String regEx = "[`~!@#$%^&*()+=|{}':;',//[//].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?]";
|
||||
String regEx = "[`~!@#$%^&*()+=|{}':;',//[//].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?]";
|
||||
Pattern p = Pattern.compile(regEx);
|
||||
Matcher m = p.matcher(str);
|
||||
return m.replaceAll("").trim();
|
||||
|
||||
@@ -64,7 +64,7 @@ public class DateUtil {
|
||||
}
|
||||
|
||||
|
||||
/*获得2个日期间的日期,包括endDate*/
|
||||
/*获得2个日期间的日期,包括endDate*/
|
||||
public static List<Date> getInDateBetweenDates(Date startDate, Date endDate) {
|
||||
if (startDate.after(endDate)) {
|
||||
return Collections.EMPTY_LIST;
|
||||
@@ -80,7 +80,7 @@ public class DateUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取去年同期的一个星期日
|
||||
* 获取去年同期的一个星期日
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@@ -91,7 +91,7 @@ public class DateUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取半年前同期的一个星期日
|
||||
* 获取半年前同期的一个星期日
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@@ -102,7 +102,7 @@ public class DateUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 去年同月的第一天
|
||||
* 去年同月的第一天
|
||||
*/
|
||||
public static Date getThisMonthInLastYear(Date date) {
|
||||
date = getDateOfLastMonth(null == date ? new Date() : date, -12);
|
||||
@@ -111,7 +111,7 @@ public class DateUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 上个月第一天
|
||||
* 上个月第一天
|
||||
*/
|
||||
public static Date getFirstDayOfLastMonth(Date date) {
|
||||
date = getDateOfLastMonth(date, -1);
|
||||
@@ -147,7 +147,7 @@ public class DateUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据日历得到那一天的星期天是哪天 注意:输入的calendar最后的值同返回值一样
|
||||
* 根据日历得到那一天的星期天是哪天 注意:输入的calendar最后的值同返回值一样
|
||||
*
|
||||
* @param calendar
|
||||
* @return
|
||||
@@ -306,7 +306,7 @@ public class DateUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 把date truncate到日期为止,去掉时分秒
|
||||
* 把date truncate到日期为止,去掉时分秒
|
||||
*
|
||||
* @param date
|
||||
* @return
|
||||
@@ -316,7 +316,7 @@ public class DateUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到这一天的范围.比如如果输入的是2007-12-12 12:36:40,则返回的是2007-12-12 00:00:00和2007-12-13
|
||||
* 得到这一天的范围.比如如果输入的是2007-12-12 12:36:40,则返回的是2007-12-12 00:00:00和2007-12-13
|
||||
* 0:0:0
|
||||
*
|
||||
* @return
|
||||
@@ -329,7 +329,7 @@ public class DateUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 转化日期成yyyy-mm-dd的String格式
|
||||
* 转化日期成yyyy-mm-dd的String格式
|
||||
*
|
||||
* @param date
|
||||
* @return
|
||||
@@ -361,7 +361,7 @@ public class DateUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 转化日期成yyyy-mm-dd hh:mm:ss的String格式
|
||||
* 转化日期成yyyy-mm-dd hh:mm:ss的String格式
|
||||
*
|
||||
* @param date
|
||||
* @return
|
||||
@@ -409,7 +409,7 @@ public class DateUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 转化日期成yyyymmddhhmmss的String格式
|
||||
* 转化日期成yyyymmddhhmmss的String格式
|
||||
*
|
||||
* @param date
|
||||
* @return
|
||||
@@ -428,7 +428,7 @@ public class DateUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 转化日期成yyyymmdd的String格式
|
||||
* 转化日期成yyyymmdd的String格式
|
||||
*
|
||||
* @param date
|
||||
* @return
|
||||
@@ -447,7 +447,7 @@ public class DateUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 转化日期HHmmss的String格式
|
||||
* 转化日期HHmmss的String格式
|
||||
*
|
||||
* @param date
|
||||
* @return
|
||||
@@ -466,7 +466,7 @@ public class DateUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 转化日期成yymmdd的String格式
|
||||
* 转化日期成yymmdd的String格式
|
||||
*
|
||||
* @param date
|
||||
* @return
|
||||
@@ -485,7 +485,7 @@ public class DateUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 转化日期成yy-mm-dd的String格式
|
||||
* 转化日期成yy-mm-dd的String格式
|
||||
*
|
||||
* @param date
|
||||
* @return
|
||||
@@ -504,7 +504,7 @@ public class DateUtil {
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* 返回之前几个月或之后几个月的今天
|
||||
* 返回之前几个月或之后几个月的今天
|
||||
*
|
||||
* @param date
|
||||
* @param num
|
||||
@@ -528,8 +528,8 @@ public class DateUtil {
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* 根据传入的日期以及数字获得当前日期之前或者之后月份的起始日期 如传入2007-06-21,6返回 日期为2007-12-1的date
|
||||
* 如传入2007-06-21,-6返回 日期为2006-12-1的date
|
||||
* 根据传入的日期以及数字获得当前日期之前或者之后月份的起始日期 如传入2007-06-21,6返回 日期为2007-12-1的date
|
||||
* 如传入2007-06-21,-6返回 日期为2006-12-1的date
|
||||
*
|
||||
* @param date
|
||||
* @param num
|
||||
@@ -585,8 +585,8 @@ public class DateUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取给定日期date向后推算num天的日期列表<br>
|
||||
* <b>注意:此时包含传入的date, 否则可设置第三个参数为false</b>
|
||||
* 获取给定日期date向后推算num天的日期列表<br>
|
||||
* <b>注意:此时包含传入的date, 否则可设置第三个参数为false</b>
|
||||
*
|
||||
* @param date
|
||||
* @param num
|
||||
@@ -597,12 +597,12 @@ public class DateUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取给定日期date向后推算num天的日期列表
|
||||
* 获取给定日期date向后推算num天的日期列表
|
||||
*
|
||||
* @param date
|
||||
* @param num
|
||||
* @param contains
|
||||
* 是否包含date
|
||||
* 是否包含date
|
||||
* @return
|
||||
*/
|
||||
public static List<Date> getBeforeDates(Date date, int num, boolean contains) {
|
||||
@@ -771,7 +771,7 @@ public class DateUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取与dete之前或后的第num个整点
|
||||
* 获取与dete之前或后的第num个整点
|
||||
*/
|
||||
public static Date getHour(Date date, int num) {
|
||||
date = DateUtils.addHours(date, num);
|
||||
@@ -805,7 +805,7 @@ public class DateUtil {
|
||||
/**
|
||||
* @param endDate
|
||||
* @param count
|
||||
* @return 自endDate始,共count个weekend的列表
|
||||
* @return 自endDate始,共count个weekend的列表
|
||||
*/
|
||||
public static List<Date> getWeekendList(Date endDate, int count) {
|
||||
if (count < 1)
|
||||
@@ -831,7 +831,7 @@ public class DateUtil {
|
||||
/**
|
||||
*
|
||||
* @param pattern
|
||||
* @return 到endMonth为止,共count个月,用pattern进行格式化
|
||||
* @return 到endMonth为止,共count个月,用pattern进行格式化
|
||||
*/
|
||||
public static List<String> formatDates(List<Date> dates, String pattern) {
|
||||
List<String> ret = new ArrayList<String>(dates.size());
|
||||
@@ -846,7 +846,7 @@ public class DateUtil {
|
||||
*
|
||||
* @param endMonth
|
||||
* @param count
|
||||
* @return 到endMonth为止,共count个月
|
||||
* @return 到endMonth为止,共count个月
|
||||
*/
|
||||
public static List<Date> getMonthList(Date endMonth, int count) {
|
||||
if (count < 1)
|
||||
@@ -900,7 +900,7 @@ public class DateUtil {
|
||||
*
|
||||
* @param endMonth
|
||||
* @param count
|
||||
* @return 自endMonth起,count个月的weekend列表
|
||||
* @return 自endMonth起,count个月的weekend列表
|
||||
*/
|
||||
public static List<Date> getWeekendListByMonth(Date endMonth, int count) {
|
||||
if (count < 1)
|
||||
@@ -961,7 +961,7 @@ public class DateUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到两个日期的差值<br>
|
||||
* 得到两个日期的差值<br>
|
||||
* between('2009-11-10', '2008-12-12', Calendar.YEAR) == 1<br>
|
||||
* between('2009-11-10', '2008-12-12', Calendar.MONTH) == 11<br>
|
||||
* between('2009-11-10', '2008-12-12', Calendar.WEEK_OF_YEAR) == 47<br>
|
||||
@@ -1052,7 +1052,7 @@ public class DateUtil {
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
// yyyy-MM-dd HH:mm:ss 24小时
|
||||
// yyyy-MM-dd HH:mm:ss 24小时
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static List<String> getDateByInterval(Date startDate, Date endDate, int interval, int calendarField, String switching,
|
||||
@@ -1108,7 +1108,7 @@ public class DateUtil {
|
||||
}
|
||||
}
|
||||
|
||||
// 推荐使用
|
||||
// 推荐使用
|
||||
@SuppressWarnings("deprecation")
|
||||
public static List<Date> getDateByIntervalL(Date startDate, Date endDate, int interval, int calendarField, String switching) {
|
||||
Date _startDate = DateUtils.truncate(startDate, calendarField);
|
||||
@@ -1165,7 +1165,7 @@ public class DateUtil {
|
||||
private static long YEAR_SEC = MONTH_SEC * 12;
|
||||
|
||||
/**
|
||||
* 获取时间与日期时间的文字描述
|
||||
* 获取时间与日期时间的文字描述
|
||||
*
|
||||
* @param date
|
||||
* @return
|
||||
@@ -1180,39 +1180,39 @@ public class DateUtil {
|
||||
long diffSec = (msNow - msInput) / 1000;
|
||||
if (diffSec < DAY_SEC) {
|
||||
if (diffSec >= HOUR_SEC) {
|
||||
return (diffSec / HOUR_SEC) + "小时前";
|
||||
return (diffSec / HOUR_SEC) + "小时前";
|
||||
} else if (diffSec >= MINU_SEC) {
|
||||
return (diffSec / MINU_SEC) + "分钟前";
|
||||
return (diffSec / MINU_SEC) + "分钟前";
|
||||
} else {
|
||||
return "刚刚";
|
||||
return "刚刚";
|
||||
}
|
||||
} else if (diffSec < MONTH_SEC) {
|
||||
return (diffSec / DAY_SEC) + "天前";
|
||||
return (diffSec / DAY_SEC) + "天前";
|
||||
} else if (diffSec < YEAR_SEC) {
|
||||
return ((int) (diffSec / MONTH_SEC)) + "月前";
|
||||
return ((int) (diffSec / MONTH_SEC)) + "月前";
|
||||
} else {
|
||||
int yearInput = inputCalendar.get(Calendar.YEAR);
|
||||
int yearNow = systemCalendar.get(Calendar.YEAR);
|
||||
return (yearNow - yearInput) + "年前";
|
||||
return (yearNow - yearInput) + "年前";
|
||||
}
|
||||
} else {
|
||||
return "刚刚";// 输入时间大于 系统时间 返回 "刚刚"
|
||||
return "刚刚";// 输入时间大于 系统时间 返回 "刚刚"
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取距离系统时间的数字型
|
||||
* FIXME:该代码有bug,(例如:2012年1月1日-2011年12月30日返回的是1年前),推荐使用getShortDateText(Date
|
||||
* 获取距离系统时间的数字型
|
||||
* FIXME:该代码有bug,(例如:2012年1月1日-2011年12月30日返回的是1年前),推荐使用getShortDateText(Date
|
||||
* date)
|
||||
*/
|
||||
public static String getDaysBeforeNow(Date date) {
|
||||
long sysTime = Long.parseLong(formatToYYYYMMDDhhmmss(new Date()));
|
||||
long ymdhms = Long.parseLong(formatToYYYYMMDDhhmmss(date));
|
||||
String strYear = "年前";
|
||||
String strMonth = "月前";
|
||||
String strDay = "天前";
|
||||
String strHour = "小时前";
|
||||
String strMinute = "分钟前";
|
||||
String strYear = "年前";
|
||||
String strMonth = "月前";
|
||||
String strDay = "天前";
|
||||
String strHour = "小时前";
|
||||
String strMinute = "分钟前";
|
||||
try {
|
||||
if (ymdhms == 0) {
|
||||
return "";
|
||||
@@ -1244,7 +1244,7 @@ public class DateUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取大概小时差
|
||||
* 获取大概小时差
|
||||
*
|
||||
* @param publishDate
|
||||
* @param strFormatter
|
||||
@@ -1255,7 +1255,7 @@ public class DateUtil {
|
||||
if (null != publishDate) {
|
||||
if (publishDate.after(range[0]) && publishDate.before(range[1])) {
|
||||
int dateDiff = DateUtil.getHour(new Date()) - DateUtil.getHour(publishDate);
|
||||
return dateDiff > 0 ? dateDiff + "小时前" : "1小时内";
|
||||
return dateDiff > 0 ? dateDiff + "小时前" : "1小时内";
|
||||
} else {
|
||||
return (DateUtil.formatByPattern(publishDate, strFormatter));
|
||||
}
|
||||
@@ -1265,7 +1265,7 @@ public class DateUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取给定日期的本周星期天
|
||||
* 获取给定日期的本周星期天
|
||||
*
|
||||
* @param date
|
||||
* @return
|
||||
@@ -1279,7 +1279,7 @@ public class DateUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取给定日期的下一个星期天
|
||||
* 获取给定日期的下一个星期天
|
||||
*
|
||||
* @param date
|
||||
* @return
|
||||
@@ -1289,7 +1289,7 @@ public class DateUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取给定日期的上一个星期天
|
||||
* 获取给定日期的上一个星期天
|
||||
*
|
||||
* @param date
|
||||
* @return
|
||||
@@ -1300,7 +1300,7 @@ public class DateUtil {
|
||||
|
||||
|
||||
/**
|
||||
* 将任意字符串将成date
|
||||
* 将任意字符串将成date
|
||||
* @param date
|
||||
* @return
|
||||
* @throws ParseException
|
||||
@@ -1309,10 +1309,10 @@ public class DateUtil {
|
||||
public static Date parseStringToDate(String date) {
|
||||
Date result = null;
|
||||
String parse = null;
|
||||
//parse=parse.replaceFirst("^.*?[0-9]{4}(年)?([^0-9]?)", "yyyy$1");
|
||||
//parse=parse.replaceFirst("([^0-9]?)[0-9]{1,2}(月)?([^0-9]?)", "$1MM$2");
|
||||
//parse=parse.replaceFirst("^.*?[0-9]{4}(年)?([^0-9]?)", "yyyy$1");
|
||||
//parse=parse.replaceFirst("([^0-9]?)[0-9]{1,2}(月)?([^0-9]?)", "$1MM$2");
|
||||
//parse=parse.replaceFirst("([^0-9]?)[0-9]{1,2}( ?)", "$1dd$2");
|
||||
Pattern p=Pattern.compile("(\\d{4})[-|年|.]?(\\d{1,2})?[-|月|.]?(\\d{1,2})?日?");
|
||||
Pattern p=Pattern.compile("(\\d{4})[-|年|.]?(\\d{1,2})?[-|月|.]?(\\d{1,2})?日?");
|
||||
Matcher m=p.matcher(date);
|
||||
|
||||
if(m.find()){
|
||||
@@ -1352,7 +1352,7 @@ public class DateUtil {
|
||||
if(dateStr == null){
|
||||
return null;
|
||||
}
|
||||
Pattern p=Pattern.compile("(\\d{1,4})[-|年|/|.]?(\\d{1,2})?[-|月|/|.]?(\\d{1,2})?日?");
|
||||
Pattern p=Pattern.compile("(\\d{1,4})[-|年|/|.]?(\\d{1,2})?[-|月|/|.]?(\\d{1,2})?日?");
|
||||
Matcher m=p.matcher(dateStr);
|
||||
String finalPattern = "yyyy";
|
||||
String pattern = "";
|
||||
|
||||
@@ -27,7 +27,7 @@ public class GeoUtils {
|
||||
|
||||
/**
|
||||
* @param raidus
|
||||
* 单位米
|
||||
* 单位米
|
||||
*
|
||||
* @return minLat,maxLat, minLng,maxLng
|
||||
*/
|
||||
@@ -53,10 +53,10 @@ public class GeoUtils {
|
||||
|
||||
|
||||
/**
|
||||
* 根据给定的经纬度、距离、角度,计算对应的经纬度
|
||||
* @param Lat 原始纬度
|
||||
* @param Lon 原始精度
|
||||
* @param distance 距离(米)
|
||||
* 根据给定的经纬度、距离、角度,计算对应的经纬度
|
||||
* @param Lat 原始纬度
|
||||
* @param Lon 原始精度
|
||||
* @param distance 距离(米)
|
||||
* @param angle , 90: right, 180: down
|
||||
* @return
|
||||
*/
|
||||
@@ -71,14 +71,14 @@ public class GeoUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* 纬度的弧度
|
||||
* 纬度的弧度
|
||||
*/
|
||||
public static double radLat(double Lat) {
|
||||
return Lat * Math.PI / 180;
|
||||
}
|
||||
|
||||
/**
|
||||
* 经度的弧度
|
||||
* 经度的弧度
|
||||
*/
|
||||
public static double eadLon(double Lon) {
|
||||
return Lon * Math.PI / 180;
|
||||
@@ -90,8 +90,8 @@ public class GeoUtils {
|
||||
return ec * Math.cos(radLat);
|
||||
}
|
||||
|
||||
final static int EARTH_RADIUS = 6378137;//赤道半径 earth radius
|
||||
final static int POLAR_RADIUS = 6356725;//极半径 polar radius
|
||||
final static int EARTH_RADIUS = 6378137;//赤道半径 earth radius
|
||||
final static int POLAR_RADIUS = 6356725;//极半径 polar radius
|
||||
public static double ecc(double Lat) {
|
||||
return POLAR_RADIUS + (EARTH_RADIUS - POLAR_RADIUS) * (90 - Lat) / 90;
|
||||
}
|
||||
|
||||
@@ -4,23 +4,23 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 分页查询值对象
|
||||
* 分页查询值对象
|
||||
* @author yinjihuan
|
||||
* @param <E> 返回数据类型
|
||||
* @param <E> 返回数据类型
|
||||
*/
|
||||
public class PageBean<E> {
|
||||
|
||||
private int start;//起始记录数
|
||||
private int start;//起始记录数
|
||||
|
||||
private int limit;//最大记录数
|
||||
private int limit;//最大记录数
|
||||
|
||||
private long totalRecords;//总记录数
|
||||
private long totalRecords;//总记录数
|
||||
|
||||
private int currentPage;//当前页
|
||||
private int currentPage;//当前页
|
||||
|
||||
private int totalPages;//总页数
|
||||
private int totalPages;//总页数
|
||||
|
||||
private List<E> list;//查询数据对象
|
||||
private List<E> list;//查询数据对象
|
||||
|
||||
public static int page2Start(int page, int limit){
|
||||
return page * limit - limit;
|
||||
|
||||
@@ -4,7 +4,7 @@ import org.apache.commons.lang.math.RandomUtils;
|
||||
|
||||
public final class RandomUtil extends RandomUtils {
|
||||
/**
|
||||
* 随机得到两个Long类型数字间任意数字
|
||||
* 随机得到两个Long类型数字间任意数字
|
||||
*
|
||||
* @param l1
|
||||
* @param l2
|
||||
@@ -17,7 +17,7 @@ public final class RandomUtil extends RandomUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* 随机得到两个Long类型数字间任意数字
|
||||
* 随机得到两个Long类型数字间任意数字
|
||||
*
|
||||
* @param i1
|
||||
* @param i2
|
||||
|
||||
@@ -24,7 +24,7 @@ public class SecurityUtil {
|
||||
Security.addProvider(new com.sun.crypto.provider.SunJCE());
|
||||
}
|
||||
|
||||
private static String Algorithm = "DES"; // 定义 加密算法,可用 DES,DESede,Blowfish
|
||||
private static String Algorithm = "DES"; // 定义 加密算法,可用 DES,DESede,Blowfish
|
||||
private static String PK = "525E9DC4D0382C4C";
|
||||
private static byte[] PK_BYTES = DataUtil.hex2byte(PK);
|
||||
private static final Pattern TOKEN_PATTERN = Pattern.compile("[A-Fa-f0-9]+");
|
||||
@@ -34,7 +34,7 @@ public class SecurityUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 加密
|
||||
* 加密
|
||||
*
|
||||
* @throws NoSuchPaddingException
|
||||
* @throws NoSuchAlgorithmException
|
||||
@@ -48,7 +48,7 @@ public class SecurityUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 解密
|
||||
* 解密
|
||||
*/
|
||||
public static byte[] decode(byte[] input, byte[] key) throws Exception {
|
||||
SecretKey deskey = new javax.crypto.spec.SecretKeySpec(key, Algorithm);
|
||||
@@ -59,7 +59,7 @@ public class SecurityUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成密钥, 注意此步骤时间比较长
|
||||
* 生成密钥, 注意此步骤时间比较长
|
||||
*/
|
||||
public static byte[] getKey() throws Exception {
|
||||
KeyGenerator keygen = KeyGenerator.getInstance(Algorithm);
|
||||
@@ -68,7 +68,7 @@ public class SecurityUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 对输入字符串进行加密
|
||||
* 对输入字符串进行加密
|
||||
*
|
||||
* @param s
|
||||
* @return
|
||||
@@ -92,7 +92,7 @@ public class SecurityUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 对输入的加密参数进行解密
|
||||
* 对输入的加密参数进行解密
|
||||
*
|
||||
* @param s
|
||||
* @return
|
||||
@@ -112,7 +112,7 @@ public class SecurityUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据tokenString得到实际的值
|
||||
* 根据tokenString得到实际的值
|
||||
*
|
||||
* @param tokenString
|
||||
* @return
|
||||
@@ -129,7 +129,7 @@ public class SecurityUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到随机的数值
|
||||
* 得到随机的数值
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@@ -148,7 +148,7 @@ public class SecurityUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是有效的验证码
|
||||
* 是否是有效的验证码
|
||||
*
|
||||
* @param tokenString
|
||||
* @param sand
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.io.*;
|
||||
public class SerializeUtil {
|
||||
|
||||
|
||||
//ĐňÁĐťŻ
|
||||
//序列化
|
||||
public static String serialize(Serializable obj) {
|
||||
ObjectOutputStream outputStream;
|
||||
ByteArrayOutputStream bai;
|
||||
@@ -24,7 +24,7 @@ public class SerializeUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
//ˇ´ĐňÁĐťŻ
|
||||
//反序列化
|
||||
public static Object unserizlize(String byt) {
|
||||
ObjectInputStream oii;
|
||||
ByteArrayInputStream bis;
|
||||
|
||||
Reference in New Issue
Block a user