From b63f41b8a0cfce68770e5cb02c8dd3fd994f0c59 Mon Sep 17 00:00:00 2001
From: chengf <2156125618@qq.com>
Date: 星期二, 22 七月 2025 18:37:54 +0800
Subject: [PATCH] 修改费用导入模块2025/07/22
---
java110-utils/src/main/java/com/java110/utils/util/Java110Converter.java | 36 ++++++++++++++++++++++++++++++++++--
1 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/java110-utils/src/main/java/com/java110/utils/util/Java110Converter.java b/java110-utils/src/main/java/com/java110/utils/util/Java110Converter.java
old mode 100644
new mode 100755
index 07cc70c..7821979
--- a/java110-utils/src/main/java/com/java110/utils/util/Java110Converter.java
+++ b/java110-utils/src/main/java/com/java110/utils/util/Java110Converter.java
@@ -6,6 +6,9 @@
import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.ZonedDateTime;
import java.util.Date;
/**
@@ -17,7 +20,7 @@
* add by wuxw 2020/1/28
**/
public class Java110Converter implements Converter {
- static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
@Override
public Object convert(Object value, Class target, Object context) {
@@ -26,6 +29,8 @@
}
public static Object getValue(Object value, Class target) {
+
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
if (value == null) {
return value;
@@ -53,6 +58,15 @@
return value;
}
+ //2.0 Date 杞� Date
+ if (value instanceof LocalDateTime && target == Date.class) {
+ ZoneId zoneId = ZoneId.systemDefault();
+ ZonedDateTime zonedDateTime = ((LocalDateTime)value).atZone(zoneId);
+ Date date = Date.from(zonedDateTime.toInstant());
+ return date;
+ }
+
+
// 3.0 Date 杞� String
if (value instanceof Date && target == String.class) {
Date date = (Date) value;
@@ -76,7 +90,7 @@
return newDate;
}
- if (value instanceof BigDecimal) {
+ if (value instanceof BigDecimal && target == String.class) {
BigDecimal bd = (BigDecimal) value;
return bd.toPlainString();
}
@@ -85,14 +99,23 @@
}
if (target == int.class || target == Integer.class) {
+ if(StringUtil.isNullOrNone(value)){
+ return 0;
+ }
return Integer.parseInt(String.valueOf(value));
}
if (target == long.class || target == Long.class) {
+ if(StringUtil.isNullOrNone(value)){
+ return 0;
+ }
return Long.parseLong(String.valueOf(value));
}
if (target == double.class || target == Double.class) {
+ if(StringUtil.isNullOrNone(value)){
+ return 0;
+ }
return Double.parseDouble(String.valueOf(value));
}
@@ -100,6 +123,15 @@
return String.valueOf(value).split(",");
}
+ //1.0 String 杞� Date
+ if (value instanceof String && target == boolean.class) {
+ String bl = (String) value;
+ if ("true".equals(bl)) {
+ return true;
+ }
+ return false;
+ }
+
return value;
}
}
--
Gitblit v1.8.0