Skip to content
This repository was archived by the owner on Oct 23, 2024. It is now read-only.
This repository was archived by the owner on Oct 23, 2024. It is now read-only.

1.2.22版本,Jdk8DateCodec里面的格式化格式不生效 #948

@ghost

Description

fastjson 1.2.22版本
Jdk8DateCodec.java

LocalDateTime dateTime = (LocalDateTime) object;
if (dateTime.getNano() == 0) {
String format = serializer.getDateFormatPattern();
if (format == null) {
format = JSON.DEFFAULT_DATE_FORMAT;
}
write(out, dateTime, format);
} else {
out.writeString(object.toString());
}

看 这里是 dateTime.getNano() == 0 才会进行format处理,LocalDateTime.now()产生的时间,都是不成立的,所以在toString时,即使是这样设置,都不会生效:
@OverRide
public String toString() {
return JSON.toJSONStringWithDateFormat(this,"yyyy-MM-dd HH:mm:ss:SSS",
SerializerFeature.DisableCircularReferenceDetect);
}

按理纳秒都要能处理啊。
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions