spring boot : Accept date in URL param

Option 1

	@RequestMapping(value = "/{customerId}/data/{startDate}/{endDate}", method = RequestMethod.GET)
	public void getUserData(@PathVariable("customerId") long customerId,
			@PathVariable("startDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) Date startDate,
			@PathVariable("endDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) Date endDate, HttpServletRequest request,
			HttpServletResponse response) throws Exception {


		//Your logic will be here :)
		
	}

 

Option 2

public void getmyData(@RequestParam("date") 
                            @DateTimeFormat(pattern = "dd-mm-yyyy") LocalDate date) {
        //Do stuff
    }

 

Author: bm on June 12, 2017
Category: Spring boot

Your comment:

Your Name

Comment:




Last articles