[QUESTION]全局将LocalDateTime日期格式化
- Dominant language
- Java
- Stars
- 4.4k
- Forks
- 613
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 6
Description
### 请描述您的问题
*通过Spring消息转换器,需要全局将LocalDateTime类型的日志格式化为:2023-07-31T05:38:39.026Z*
目前是没有T Z的,用的是好早之前wenshao给的一个方案:
// 自定义LocalTime序列化格式
JSON.register(LocalDateTime.class, (jsonWriter, object, fieldName, fieldType, features) -> {
if (object == null) {
jsonWriter.writeNull();
return;
}
LocalDateTime localTime = (LocalDateTime) object;
jsonWriter.writeString(localTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS")));
});
Contributor guide
Research direction
Start by reviewing the Spring message converter context and the provided LocalDateTime serializer registration. No source file, test, or specific change is named in the issue, so first determine where global date-time formatting is configured and what behavior should be verified for the requested UTC-style output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100