Quick-Tip: Solve Problems with Date/Time Fields

Sunday, December 7, 2014 9:19 AM UTC

A few weeks ago I noticed a weird behavior of date/time fields in an XPage on my website when creating or editing a blog post. The post date is a simple date/time edit box with a converter set to full date and short time. As I mostly create new entries on the webserver directly I was annoyed that the field was always set to minus one hour after every save action. Another problem was that the date was displayed diffently on the blog post list on the homepage than it was when opening the post - maybe you noticed that already.

I thought it was my fault but it wasn't. I tested this on several other machines and it all worked well. So this was an issue on my webserver that is hosted by a provider. I didn't set up this machine for myself to I wasn't sure if the timezone on the server was set correctly (or even set to something). I set it manually with

dpkg-reconfigure tzdata

as this is a Linux machine.

But that didn't do the trick, so this issue was Domino related for sure. I really don't know why but setting the timezone attribute for that control fixed that issue.

So the tip is: always set a timezone for a date/time field on your XPage to avoid problems like that.

<xp:inputText

 value="#{document1.postDate}"

 id="postDate1"

 styleClass="dtpicker">

 <xp:this.converter>

     <xp:convertDateTime

         type="both"

         dateStyle="short"

         timeZone="UTC">

     </xp:convertDateTime>

 </xp:this.converter>

 <xp:dateTimeHelper

     id="dateTimeHelper1">

 </xp:dateTimeHelper>

</xp:inputText>

 






Leave a comment right here