I have a Play application that should list out purchases within a given date interval. If the user does not give any date interval, it should default to showing purchases within the last year. This is done with these two methods in my controller:
public static void show(String id) {
Date today = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(today);
calendar.add(Calendar.YEAR, -1);
Date oneYearAgo = calendar.getTime();
showWithInterval(id, oneYearAgo, today);
}
public static void showWithInterval(String id, Date fromDate, Date toDate) {
List<Purchase> purchases= Purchase.find(id, fromDate, toDate);
render(purchases, fromDate, toDate);
}
However, this produces a url looking like this: http://localhost:9000/purchases/showwithinterval/10076430719?fromDate=ISO8601:2010-01-17T19:41:20%2B0100&toDate=ISO8601:2011-01-17T19:41:20%2B0100
This does not adhere to the date format I have specified with the date.format
property in application.conf
. This format is simply not usable, as I want to be able to print the dates (using ${params.fromDate}
) and let my users edit them to show other intervals. I cannot format them in the view, since they are strings.
Does anyone know how to fix this?
Edit: Fixed a typo