This commit is contained in:
zt
2025-02-26 18:43:45 +08:00
parent 6ef339849e
commit 65ce01c325
29 changed files with 671 additions and 49 deletions

View File

@ -5,6 +5,8 @@ import org.apache.commons.lang3.time.DateFormatUtils;
import java.lang.management.ManagementFactory;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Date;
/**
@ -157,4 +159,19 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
// long sec = diff % nd % nh % nm / ns;
return day + "" + hour + "小时" + min + "分钟";
}
public static LocalDate str2Localdate(String time,String format){
// 定义日期格式
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(format);
LocalDate localDate = null;
try {
// 将字符串转换为 LocalDate
localDate = LocalDate.parse(time, formatter);
} catch (Exception e) {
System.out.println("日期格式不正确,转换失败: " + e.getMessage());
}
return localDate;
}
}