Customizing the Date format from Velocity Expressions in HTML Form Entry

In my forms, dates are returned using the format 01/04/2016 for HTML form entry obs tags, but are returned as 14/Jan/2016 when using velocity expressions like ${myobs.obsDatetime} in the lookup tag.

Has anybody been able to customize the date format used within velocity to match that used within the HTML form entry tags?

Hi,

I wrote a Groovy logic rule for this for one specific date format for birthdates for an implementation we have (on an ancient OpenMRS 1.6.x setup). I essentially took the date of birth and arranged individual fields from it into the format I needed. I then used lookup fn.logic to run the rule and output the date.

I don’t know if one could use Groovy to write a generalized data format rule though. I imagine a more general logic rule could also be written in Java using a DateFormatter?

There may be more elegant solutions of course :slight_smile:

Ali

Ali Habib Chief Executive Officer Interactive Health Solutions Ph: +92-21-34327697 ali.habib@irdresearch.org

@ahabib Do share a link to the Groovy logic rule, elegance will come later

Here you go: http://pastebin.com/4y95srun

The format in question was dd.mm.yyyy

Ali

Ali Habib Chief Executive Officer Interactive Health Solutions Ph: +92-21-34327697 ali.habib@irdresearch.org

@ahabib Thanks