I am using a FileDownload control to show a list of attachments from a Notes document.
The dates are shown as: dd/MM/yy hh.mm – and since my users are Danish I would like to show the dates in the format: dd-MM-yyyy hh:mm.
That is pretty simple if you use a SimpleDateFormater. In SSJS that would look like:
var date:Date = new Date(aFile.getCreated());
if(date==null) return date;
return new java.text.SimpleDateFormat("dd-MM-yy hh:mm").format(date);
In the FileDownload control you can compute the value of “createdValue” property. However, the control expects an object of type “Date” which does not allow for the formating in the above example (it just throws an Error 500).
Any suggestions?
/John
You already found that the createdValue property expects a java.util.Date object, so the only way to change how that is formatted is by changing the browser locale used by the XPage (as answered here). Using the standard download control you can get a handle on every file by adding the var=”file” attribute to it and use that in the createdValue property:
If you want to have more control on the list of files you could use a repeat control and bind it to the list of files from a RichText item:
By the way: another a disadvantage of the default download control is that it adds a content-disposition header to every link, so the browsers always asks you if you want to save or open the file instead of opening images (for instance) directly.