RPE automatically parses dates and renders them as instructed ( date formatting property in the docspec or date pattern property in the template) but it can only do so if the element’s type in the schema is a date/time type.
When the schema does not provide the required type info or when you need to parse dates introduced by user ( in a variable) you need to do it through Java Script. A snippet showing how to parse dates that are not automatically recognized by RPE and render them in a nice format.
// replace this with your actual attribute/template variable var vdt = my_date_attr; try { // change this to match your input date format var fmt_in = new java.text.SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss"); // change this to produce the desired output format. You could use an external variable to customize the pattern at runtime var fmt_out = new java.text.SimpleDateFormat( "MMMM dd, yyyy HH:mm:ss"); // parse the input string. if errors occur they will be caught in the catch block var dt =fmt_in.parse(vdt); // render the date in the new format. This is the result of the expression fmt_out.format(dt); } catch(err) { java.lang.System.out.print( err); // return the original value vdt; }
Advertisements
wow, that’s a helpful code with error handling 🙂
Hi Dragos,
is there any way to safe an attachment of a jazz artifact to which an URL exists in the file system of the machine running the RPE launcher?
Thanks Stefan
Hey Stefan,
RPE can include certain document types in the Word/PDF output through the “INCLUDE FILE” element. You need to set the “include type” property of the element to “physical embedding”. This however only supports a limited number of formats ( such as Word documents) and will embed the content.
If you need to download the files you need to use an external tool ( like curl – http://curl.haxx.se/) and invoke it from a JavaScript code in RPE.
Hope this helps.
Regards,
Dragos