升级框架后发现Feign调用失败时间格式化问题的排查和解决
· 7 min read
升级内部框架版本后,发现Feign调用失败,报错如下:
Failed to convert value of type 'java.lang.String' to required type 'java.time.ZonedDateTime';
nested exception is org.springframework.core.convert.ConversionFailedException:
Failed to convert from type [java.lang.String] to type [@org.springframework.web.bind.annotation.RequestParam @org.springframework.format.annotation.DateTimeFormat java.time.ZonedDateTime] for value '2023/12/18 02:57';
nested exception is java.lang.IllegalArgumentException: Parse attempt failed for value [2023/12/18 02:57]
客户端伪代码如下:
public interface FeignClient {
@GetMapping("/")
List<PlatformStandardOrderDto> test(
@RequestParam ZonedDateTime startTime,
@RequestParam ZonedDateTime endTime
);
}
这个问题的现象是Feign调用时参数中的ZonedDatetime
类型的时间格式化的结果服务端无法解析