解析格式化时间

This commit is contained in:
ZLI263
2025-09-24 12:41:32 +08:00
parent f727175bca
commit 2b04df3b7d

View File

@@ -26,6 +26,7 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
@@ -225,16 +226,24 @@ public class TmNameplateCorpusServiceImpl extends ServiceImpl<TmNameplateCorpusM
}else {
try {
log.info("getNameplateEndTime is not null");
// 定义原始字符串的格式注意CST 在这里是中国标准时间,对应 Asia/Shanghai
SimpleDateFormat inputFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss 'CST' yyyy");
inputFormat.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai")); // 设置时区为 CST (China Standard Time)
ZonedDateTime zonedDateTime = ZonedDateTime.parse(item.getNameplateEndTime().toString());
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
String formattedDateStartTime = zonedDateTime.format(formatter);
inputMap2.put("communicateDate", formattedDateStartTime);
// 定义目标格式
SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// 解析原始字符串为 Date 对象
Date date = inputFormat.parse(item.getNameplateEndTime().toString());
// 格式化为目标格式
String formattedDate = outputFormat.format(date);
inputMap2.put("communicateDate", formattedDate);
}catch (Exception e){
log.info("getNameplateEndTime {}", e.getMessage());
}
}
log.info("getNameplateEndTime");
log.info("getNameplateEndTime,inputMap2,",inputMap2);
diFyImageReq2.setUser(ConstantStr.corpus_user);
inputMap2.put("businessId", item.getCustomerFlowId());
@@ -356,7 +365,7 @@ public class TmNameplateCorpusServiceImpl extends ServiceImpl<TmNameplateCorpusM
aiAnalysisErrorsMapper.update(AiAnalysisErrors.builder().aiAnalysisRequestId(oldAiAnalysisErrors.getAiAnalysisRequestId()).aiAnalysisErrorHandlingStatus("1").build(), errorQueryWrapper);
}
} else {
log.info("没找到语料记录");
log.info("没找到语料记录,{}",message);
}
return ResultMsg.ok();
}