public String findJobsInOneDay(@RequestParam("date") String date, Map<String, Object> model) throws ParseException {
final long startTime = System.currentTimeMillis();
+ String realdate;
final SimpleDateFormat formaterDDMMYY = new SimpleDateFormat("dd/MM/yyyy");
final SimpleDateFormat formaterYYMMDD = new SimpleDateFormat("yyyy/MM/dd");
- String date1 = formaterYYMMDD.format(new Date(formaterDDMMYY.parse(date).getTime()));
-
+ try {
+ long thetime = formaterYYMMDD.parse(date).getTime();
+ if (thetime < 0) {
+ realdate = date;
+ } else {
+ realdate = formaterDDMMYY.format(new Date(thetime));
+ }
+ } catch (ParseException e) {
+ realdate = date;
+ }
+
CassandraRequester cr = new CassandraRequester();
- //List<DataBase> r1 = cr.countJobs(date1, date1);
- List<DataBase> r = cr.readJobByDay(date);
+ // IMPORTANT: input should be suppied in the format: DD/MM/YYYY
+ List<DataBase> r = cr.readJobByDay(realdate);
model.put("results", r);
model.put("njobs", r.size());
- model.put("date", date1);
+ model.put("date", realdate);
final long endTime = System.currentTimeMillis();
model.put("timeExecution", (endTime - startTime));
- System.out.println("Request for date = " + date1 + ": " + r.size() + " jobs found");
return "/reportJobStatisticsOneDay";
}
}