I need to match a (partial) searchstring to a Date with timestamp from the database.
I have a searchbox that allows you to search through 4 values at once. Those being: code, date, name and code2. When you input a value I make a new List with all the valid searchresults. At the moment everything works except my date, I can search on the independent numbers but when I use the following format I get a 404.
("dd/MM/yyyy")
Now I do have a formatter in place to transform my Date from the database (format = "yyyy-mm-dd hh:mm:ss") into a String. However I keep having the same problem. The moment I enter / into the searchbox it won't generate my list anymore and I get the 404.
And I was wondering what the best solution would be? Transform everything into a String, transform the searchstring into a Date format + 00:00:00 or change something in the searchbox so that it only looks for a date if the format matches exactly?
if (orderHeader.getCode() != null) {
orderHeaderDTO.setCode(orderHeader.getCode());
}
if (orderHeader.getOrderDate() != null) {
while (searchString.contains("/")) {
Date date = orderHeader.getOrderDate();
String dateString = DateUtil.convertDateToString(date);
if (dateString == searchString) {
orderHeaderDTO.setOrderDate(date);
}
}
able to search with the following format = "dd/MM/yyyy" & not get a 404 or a 500 error