Skip to content

Tag: java

Java 8 calculate how many 1st of the months between two dates

I have two dates: I want the result = 1 (for the date, 2022-04-01) Answer tl;dr See this code run live at IdeOne.com. 1 Details First, parse the inputs as LocalDate objects. The LocalDate#datesUntil method creates a stream of LocalDate objects between the two values. We can filter that stream to keep only the…

Generic restTemplateExchange with generic responseType

I would like to create a own generic method that calls the restTemplate.exchange. In particular I would like that the signature of this generic method to be : I would differentiate what exchange method call according to “responseType” if responseType is Class< T> I call * exchange(URI url, H…