|
|
@@ -284,14 +284,26 @@ public class CheckInsPlyComeUtils {
|
|
|
}
|
|
|
|
|
|
private static String pareDateToLocalTime(Date getSignDateNew) {
|
|
|
-
|
|
|
+ if (getSignDateNew == null) {
|
|
|
+ // 对传入的Date对象做判空处理,避免空指针异常,这里简单返回null,可根据实际需求调整
|
|
|
+ return null;
|
|
|
+ }
|
|
|
Instant instant = getSignDateNew.toInstant();
|
|
|
ZoneId zoneId = ZoneId.systemDefault();
|
|
|
- LocalDate localDate = instant.atZone(zoneId).toLocalDate();
|
|
|
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
- String formattedDate = localDate.format(formatter);
|
|
|
- String singTime = pareTimeLocalDate(formattedDate);
|
|
|
- return singTime;
|
|
|
+ LocalDateTime localDateTime = instant.atZone(zoneId).toLocalDateTime();
|
|
|
+ // 通过判断LocalDateTime的时间部分是否都是0来确定是否只包含日期(即没有时分秒)
|
|
|
+ boolean isOnlyDate = localDateTime.toLocalTime().equals(java.time.LocalTime.of(0, 0, 0));
|
|
|
+
|
|
|
+ if (isOnlyDate) {
|
|
|
+ // 说明没有时分秒,只有日期部分,按原逻辑格式化日期
|
|
|
+ DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+ String formattedDate = localDateTime.toLocalDate().format(dateFormatter);
|
|
|
+ return pareTimeLocalDate(formattedDate);
|
|
|
+ } else {
|
|
|
+ // 带有时分秒,使用包含时分秒的格式化方式,这里可以根据需求调整格式,比如"yyyy-MM-dd HH:mm:ss"
|
|
|
+ DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+ return localDateTime.format(dateTimeFormatter);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private static String pareTimeLocalDate(String signDate) {
|