Spring Boot search data between two dates
It's best that you receive the parameters as String and then convert the String to LocalDate in your controller.
@RequestMapping(value="/movementsByDate", method = RequestMethod.GET)
public Page<Mouvements> movementsByDate(
@RequestParam(name= "dateBefore", defaultValue="")String dateBeforeString,
@RequestParam(name= "dateAfter", defaultValue="")String dateAfterString,
@RequestParam(name= "page", defaultValue="0")int page,
@RequestParam(name= "size", defaultValue="5")int size){
LocalDate dateBefore = LocalDate.parse(dateBeforeString, DateTimeFormatter.ofPattern("dd/MM/yyyy"));
LocalDate dateAfter = LocalDate.parse(dateAfterString, DateTimeFormatter.ofPattern("dd/MM/yyyy"));
return mouvementsRepository.getMouvementsByDate(dateBefore, dateAfter, new PageRequest(page, size));
}
Searching an order between two dates Hibernate, Spring Boot
Create a method like this in your repository
public List<Orders> findByDateBetween(Date from, Date to)
spring-data will take care of the rest. This will fetch the orders which has date between from and to
Related Topics
How to Check Whether a Given String Is Valid Json in Java
How to Check If an Excel Cell Is Empty Using Apache Poi
Spring @Value Annotation Always Evaluating as Null
Looping Within Multiple Arrays in Java Stream
In Java, How to Determine If a Char Array Contains a Particular Character
Creating a Composite Unique Constraints on Multiple Columns
Base64: Java.Lang.Illegalargumentexception: Illegal Character
The Group Coordinator Is Not Available-Kafka
Split a List into Sublists Based on a Condition With Stream API
Spring @Transaction Method Call by the Method Within the Same Class, Does Not Work
How to Pass JavaScript Values to Scriptlet in Jsp
How to Set Default Download Directory in Selenium Chrome Capabilities
Enter Array Without Knowing Its Size
Remove Trailing Comma from Comma-Separated String
Retrieving Data from Biometric Fingerprint Attendance Device