PermaLink Formatting dates in Lotus Component Designer02/22/2007 08:39 AM
Lotus Component Designer
Ok, this is not the most exciting topic to write about.  The formatting of dates in LCD has just come up a number of times over the past week with a number of different developers.  So I figure there are many other people with the same issue.  

Each developer has tried various techniques without success and left it to come back to later.  The issue seems to be that the date/time value is stored or translated into the "International" format within XML.  When using an Edit Box control or Date Time Picker control, the data is then translated based on the selections on the properties page for that control.  When using a javascript formula to create text to display that contains a date, you need to format the date yourself.  I've tried the old @Text() formula, but no luck.

Here's the solution I have used for formatting dates in javascript.  There is a class that contains methods for internationalization.  Most people overlook this in the help.  Actually, no one I know has found this class on their own.  The class name is "I18n"...sounds so obscure so no one seems to click on it to see what it does.  

I use the I18n "toString" method to format my dates.  It works great.  Here is what the help says about this method:

Produces a string value that represents the date formatted according to the given pattern and according to the conventions of the given locale. The pattern may be one of the six predefined patterns represented by i18n constants (DATE_FORMAT, LONG_DATE_FORMAT, etc. )

toString(date:Date, pattern:string) : string

I put together a small helper method for the most common date/time format.  I am using the standard DATETIME_FORMAT which would display the date and time such as "2/22/2007 1:58 PM".

formatDT(theDate){

return I18n.toString(theDate,I18n.DATETIME_FORMAT);

}

If anyone has come across any other solutions, please share it by adding a comment.

John

Technorati:
This page has been accessed 24 times. .
Comments :v
No comments.
Search
XPage Examples
By Category
My Links
Downloads
Monthly Archive
Powered by
Blogsphere
Lotus Domino ND7 RSS News Feed RSS Comments Feed Geo URL netcraft RSS Validator Lotus Geek Chris. A. Brandlehner OpenNTF BlogSphere
Calendar
No calendar found.
The BlogRoll