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

Commit

Permalink
Merge pull request #3288 from ZivYan/issue#3287
Browse files Browse the repository at this point in the history
修复在JodaCodec中 write 指定 SerializerFeature WriteDateUseDateFormat 无效的问题 #3287
  • Loading branch information
wenshao authored Jun 25, 2020
2 parents 369dda7 + 8f73f5f commit 2646f10
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/main/java/com/alibaba/fastjson/serializer/JodaCodec.java
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,8 @@ public void write(JSONSerializer serializer, Object object, Object fieldName, Ty
if (format == null) {
if ((features & mask) != 0 || serializer.isEnabled(SerializerFeature.UseISO8601DateFormat)) {
format = formatter_iso8601_pattern;
} else if (serializer.isEnabled(SerializerFeature.WriteDateUseDateFormat)) {
format = JSON.DEFFAULT_DATE_FORMAT;
} else {
int millis = dateTime.getMillisOfSecond();
if (millis == 0) {
Expand All @@ -453,9 +455,6 @@ public void write(JSONSerializer serializer, Object object, Object fieldName, Ty

if (format != null) {
write(out, dateTime, format);
} else if (out.isEnabled(SerializerFeature.WriteDateUseDateFormat)) {
//使用固定格式转化时间
write(out, dateTime, JSON.DEFFAULT_DATE_FORMAT);
} else {
out.writeLong(dateTime.toDateTime(DateTimeZone.forTimeZone(JSON.defaultTimeZone)).toInstant().getMillis());
}
Expand Down

0 comments on commit 2646f10

Please sign in to comment.