Tuesday, October 8, 2013

Configuring input field for DateTime picker with localized date/time format

In a new application a colleague of mine is working on, he wanted to let the user set date and time with Norwegian date and time format.

One would think it should be pretty straightforward, but it took me around three hours to figure out how to do it. I accidentally discovered the way to do it while making a custom control with one field for date and one field for time. The custom control was meant to combine the two values into a date/time value. Luckily there's a simpler solution.

Source for Norwegian Date/Time picker:
<xp:inputText id="dateTimePicker" value="#{document.date_time}">
  <xp:convertDateTime pattern="dd.MM.yyyy HH:mm" type="both" />
   <xp:dojoAttribute name="constraints" value="{ datePattern : 'dd.MM.yyyy', locale: 'no', timePattern: 'HH:mm' }" />

I tested/this should work on Domino 8.5.3 and Domino 9.