LAPTOP-KB9HII50\70708 2 lat temu
rodzic
commit
2e3f729344

+ 11 - 47
common/common-util/src/main/java/com/yihu/jw/util/date/DateUtil.java

@ -6,8 +6,6 @@ import org.springframework.util.StringUtils;
import java.math.BigDecimal;
import java.sql.Time;
import java.sql.Timestamp;
import java.text.ParseException;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.time.*;
import java.time.format.DateTimeFormatter;
@ -1427,19 +1425,15 @@ public class DateUtil {
    }
    public static String getNowDateTime() {
        SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss", Locale.JAPAN);
        df.setTimeZone(TimeZone.getDefault());
        return df.format(new java.util.Date());
        return dateToStringLong(new Date(),YYYYMMDDHHMMSS);
    }
    public static Timestamp getSysDateTime() {
        return new Timestamp(Calendar.getInstance().getTime().getTime());
        return new Timestamp(new Date().getTime());
    }
    public static Time getSysTime() {
        return new Time(Calendar.getInstance().getTime().getTime());
        return new Time(new Date().getTime());
    }
@ -1467,24 +1461,11 @@ public class DateUtil {
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        return sdf.format(date);
        return dateToStr(date,format);
    }
    public static Date parseDate(String value, String pattern) {
        try {
            TimeZone tz = TimeZone.getDefault();
            String dateFormat = pattern;
            SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
            sdf.setTimeZone(tz);
            // Parse date
            java.util.Date parsed = null;
            parsed = sdf.parse(value);
            return parsed;
        } catch (ParseException e) {
            return null;
        }
        return strToDate(value,pattern);
    }
    public static Timestamp formatYMDToYMDHMS(String str) {
@ -1492,9 +1473,7 @@ public class DateUtil {
            return null;
        }
        str += " 00:00:00";
        SimpleDateFormat sdf = new SimpleDateFormat(YYYY_MM_DD_HH_MM_SS);
        ParsePosition pos = new ParsePosition(0);
        java.util.Date date = sdf.parse(str, pos);
        java.util.Date date = strToDateLong(str);
        if (date == null) {
            return null;
        }
@ -1503,11 +1482,9 @@ public class DateUtil {
    }
    public static Timestamp fromatDateToTimestamp(Date date) {
        Timestamp ts = new Timestamp(System.currentTimeMillis());
        Timestamp ts = null;
        try {
            SimpleDateFormat df = new SimpleDateFormat(YYYY_MM_DD_HH_MM_SS);
            String time = df.format(date);
            ts = Timestamp.valueOf(time);
            ts = new Timestamp(date.getTime());
        } catch (Exception e) {
            return null;
        }
@ -1528,16 +1505,7 @@ public class DateUtil {
            throw new IllegalArgumentException("The value of an argument is inaccurate.");
        }
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        ParsePosition pos = new ParsePosition(0);
        java.util.Date date = sdf.parse(str, pos);
        if (date == null) {
            return null;
        }
        return new Date(date.getTime());
        return strToDate(str,format);
    }
    public static Date formatCharDateYMD(String yy, String mm, String dd) {
@ -1563,11 +1531,7 @@ public class DateUtil {
        return getDifferenceOfDays(dateFrom, dateTo);
    }
    public static String formatDate(java.util.Date value, String pattern) {
        TimeZone tz = TimeZone.getDefault();
        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
        sdf.setTimeZone(tz);
        return sdf.format(value);
    public static String formatDate(Date value, String pattern) {
        return dateToStr(value,pattern);
    }
}