chengf
2025-07-25 ee4d1b668d1666cdec803b037ce8181763154bb6
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;
/**
@@ -55,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;
@@ -78,7 +90,7 @@
            return newDate;
        }
        if (value instanceof BigDecimal) {
        if (value instanceof BigDecimal && target == String.class) {
            BigDecimal bd = (BigDecimal) value;
            return bd.toPlainString();
        }
@@ -87,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));
        }