swagger Failed to convert value of type ‘java.lang.String‘ to required type ‘java.util.Date

使用@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")  日期格式可自行更改

public HttpResponse getScaleResource(@RequestParam(name = "resourceType", required = false)  @ApiParam(value = "资源类型") String resourceType,
                                         @RequestParam(name = "status", required = false)  @ApiParam(value = "状态") Integer status,
                                         @RequestParam(name = "startTime", required = false) @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") @ApiParam(value = "开始时间", format = "yyyy-MM-dd HH:mm:ss", example = "2024-01-01 10:10:10") Date startTime,
                                         @RequestParam(name = "endTime", required = false) @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") @ApiParam(value = "结束时间", format = "yyyy-MM-dd  HH:mm:ss", example = "2024-01-01 10:10:10") Date endTime,
                                         @RequestParam(name = "pageSize") @Validated @ApiParam(value = "每页数", required = true) Long pageSize,
                                         @RequestParam(name = "pageNum")  @Validated @ApiParam(value = "页数", required = true) Long pageNum
    ){
        IPage list = scaleService.getScaleResource(resourceType, status,  startTime, endTime,  pageSize, pageNum);
        return new HttpResponse<>().success(list);
    }

你可能感兴趣的:(java,windows,开发语言)