|
@@ -1,6 +1,8 @@
|
|
|
package com.mixsmart.utils;
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.util.HashUtil;
|
|
|
+import cn.hutool.core.util.RadixUtil;
|
|
|
import cn.hutool.dfa.SensitiveUtil;
|
|
|
import com.jfireel.expression.Expression;
|
|
|
import org.apache.commons.collections4.MapUtils;
|
|
@@ -12,6 +14,7 @@ import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.LocalTime;
|
|
|
+import java.time.ZoneId;
|
|
|
import java.util.*;
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
@@ -1014,13 +1017,14 @@ public class CustomFunction {
|
|
|
if(d!=null){
|
|
|
cal.setTime(d);
|
|
|
cal.add(Calendar.DATE,StringUtils.handObj2Integer(n));
|
|
|
- if(date.toString().contains("-")){
|
|
|
- return dateToStr(cal.getTime(),"yyyy-MM-dd");
|
|
|
- } if(date.toString().contains("年")){
|
|
|
- return dateToStr(cal.getTime(),"yyyy年MM月dd日");
|
|
|
- }else{
|
|
|
- return dateToStr(cal.getTime(),"yyyy.MM.dd");
|
|
|
- }
|
|
|
+// if(date.toString().contains("-")){
|
|
|
+// return dateToStr(cal.getTime(),"yyyy-MM-dd");
|
|
|
+// } if(date.toString().contains("年")){
|
|
|
+// return dateToStr(cal.getTime(),"yyyy年MM月dd日");
|
|
|
+// }else{
|
|
|
+// return dateToStr(cal.getTime(),"yyyy.MM.dd");
|
|
|
+// }
|
|
|
+ return cal.getTime();
|
|
|
}
|
|
|
}
|
|
|
return "";
|
|
@@ -1281,6 +1285,9 @@ public class CustomFunction {
|
|
|
t2=year+mstr+dstr+t2;
|
|
|
return timePassed(t1,t2,"m",0,"yyyy-MM-dd HH:mm");
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
public static Object hoursPassedRecent(Object t1,Object t2){
|
|
|
String year = Calendar.getInstance().get(Calendar.YEAR)+"年";
|
|
|
t1=year+t1;t1=t1.toString().replace("日"," ").replace("时"," ");
|
|
@@ -1317,11 +1324,15 @@ public class CustomFunction {
|
|
|
}
|
|
|
return datetime;
|
|
|
}
|
|
|
- public static Date parseDate(String dateStr,String format) {
|
|
|
- if(StringUtils.isEmpty(dateStr)||StringUtils.isEmpty(format)) {
|
|
|
+ public static Date parseDate(Object date,String format) {
|
|
|
+ if(date instanceof Date){
|
|
|
+ return (Date) date;
|
|
|
+ }
|
|
|
+ if(date==null||StringUtils.isEmpty(format)) {
|
|
|
return null;
|
|
|
}
|
|
|
- if(!dateStr.contains("-")){
|
|
|
+ String dateStr=date.toString();
|
|
|
+ if(!dateStr.toString().contains("-")){
|
|
|
Matcher m = RegexUtils.matcher("\\d{4}(.)\\d{2}(.)\\d{2}(日?)",dateStr);
|
|
|
if(m.find()){
|
|
|
Set<String> set = new HashSet<>();
|
|
@@ -1362,10 +1373,9 @@ public class CustomFunction {
|
|
|
* @Date 2021.07.01 09:57
|
|
|
**/
|
|
|
public static Object timePassed(Object t1,Object t2,Object mode,Object scale,Object format){
|
|
|
- if(StringUtils.isNotEmpty(t1)&&StringUtils.isNotEmpty(t2)&&StringUtils.isNotEmpty(mode)&&StringUtils.isNotEmpty(scale)&&StringUtils.isNotEmpty(format)){
|
|
|
-// mode=mode.toString().toUpperCase();
|
|
|
- Date d1 = parseDate(handleNull(t1),handleNull(format));
|
|
|
- Date d2 = parseDate(handleNull(t2),handleNull(format));
|
|
|
+ if(t1!=null&&t2!=null&&StringUtils.isNotEmpty(mode)&&StringUtils.isNotEmpty(scale)&&StringUtils.isNotEmpty(format)){
|
|
|
+ Date d1 = parseDate(t1,handleNull(format));
|
|
|
+ Date d2 = parseDate(t2,handleNull(format));
|
|
|
assert d2 != null;
|
|
|
assert d1 != null;
|
|
|
if(d1.after(d2)&&StringUtils.isEquals("H",mode)){
|
|
@@ -3430,17 +3440,7 @@ public class CustomFunction {
|
|
|
|
|
|
|
|
|
|
|
|
-// public static void main(String[] args) {
|
|
|
-// List<Object> list = new ArrayList<>(Arrays.asList(1,2,2,4,5,6,7,8,9,0));
|
|
|
-//
|
|
|
-// Set<String> set = new HashSet<>(20);
|
|
|
-// set.add("yang");
|
|
|
-// set.add("yu");
|
|
|
-// set.add("jiu");
|
|
|
-// SensitiveUtil.init(set);
|
|
|
-// System.out.println(SensitiveUtil.getFoundAllSensitive("yang are good man"));
|
|
|
-//
|
|
|
-// }
|
|
|
+
|
|
|
|
|
|
|
|
|
|