Custom Date and Time format for a Locale using .df files

Why the locale files (.df) needed

Some locales not support some of the date time formats which was usually supported by other locales. For example, English (Australian) doesn't support the date format with hyphen (i.e 01-01-2000 00:00:00). So the .df files provides the options to support custom date and time formats.

How/Where to add the locale file

Create the following files [Locale_ID-datetime.df (for date time formats), Locale_ID-date.df (for date formats) or Locale_ID-time.df (for time formats)] with the format you want to supports in the following directory [<web-context>/lucee/locales/] and restart lucee.

Example for English (Australian) create a file en-AU-datetime.df in WEB-INF/lucee/locales/ with below content

MM-dd-yyyy HH:mm:ss

And restart lucee/tomcat.

So now the lsParseDateTime() with locale en_AU (English (Australian)) supports date time string like 01-01-2000 00:00:00.

If you want to add more formats to be supported. Append the format you want to support in a new line on that file like

MM-dd-yyyy HH:mm:ss
yyyy/MM/dd HH:mm:ss
yyyy-MM-dd HH:mm:ss
yyyy-MM-dd
yyyy/MM/dd

So now these formats are supported by the lsParseDateTime() with locale en_AU (English (Australian)).

Info

Note: the locale file needs the java masks (ex: mm for Minute) for that from here SimpleDateFormat (Java Platform SE 7 ).

See also