Skip to content

Document the types to which each spring.mvc.format and spring.webflux.format property applies #41482

Closed
@relufi

Description

@relufi

config:

format:
  date-time: yyyy-MM-dd HH:mm:ss
  date: yyyy-MM-dd
  time: HH:mm:ss

code:

public record TestParam(Date updateTime){
}
@GetMapping("/test")
public void list(TestParam bo) {
    System.out.println("rec: " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(bo.updateTime()));
}

request: url param updateTime: 2024-07-18 02:00:10

GET http://localhost/test?updateTime=2024-07-18%2002%3A00%3A10

Current Output:

rec: 2024-07-18 00:00:00

Expected Output:

rec: 2024-07-18 02:00:10

With the same configuration, using the LocalDateTime class to receive parameters results in successful conversion.

I took a quick look at the code, and it seems that the String to Date converter only utilizes the spring.mvc.format.date configuration and ignores the spring.mvc.format.time and spring.mvc.format.date-time configurations.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions