Get Value from URL parameter with GetMapping ~ LocalDate ~

Get Value from URL parameter with GetMapping ~ LocalDate ~

――I'm posting it as my own memo.

@RestController
@RequestMapping(value = "/date/{from}/{to}", method = RequestMethod.GET)

public class CsvController {

    @GetMapping
    public String get(@DateTimeFormat(pattern = "yyyy-MM-dd") @PathVariable LocalDate from,
                      @DateTimeFormat(pattern = "yyyy-MM-dd") @PathVariable LocalDate to) {
        return "fromDate:" + from.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))
               + "toDate:" + to.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
    }
}


Recommended Posts

Get Value from URL parameter with GetMapping ~ LocalDate ~
[Java] Get Json from URL and handle it with standard API (javax.script)
Get "2-4, 7, 9" from [4, 7, 9, 2, 3]
[Java] Get multiple values from one return value
[Java] Get a random value from an array
[LeJOS] Get EV3 sensor value remotely with Java
How to get jdk etc from oracle with cli