Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ghost opened this issue Dec 12, 2016 · 1 comment
Closed

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

ghost opened this issue Dec 12, 2016 · 1 comment
Labels
Milestone

Comments

@ghost
Copy link

ghost commented Dec 12, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant