下面以fastjson 1.2.56版本为例

      <dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.56</version>
</dependency>

在FastJsonConfig中配置 以LocalDateTime

.setSerializeFilters((ValueFilter) (o, s, source) -> {
if (source == null) {
return "";
}
if (source instanceof LocalDateTime) {
return ((LocalDateTime) source).toInstant(ZoneOffset.of("+8")).toEpochMilli();
}
return source;
});

参考自:​​https://github.com/alibaba/fastjson/issues/1546​