Not yet rated

Problem

While running ColdFusion, it basically uses the system locale which is available on the server's JVM level. While formatting locale related data, we may require to switch current locale.

Solution

The locale should be updated as requested/required locale.

Detailed explanation

We can change the locale which is used to format locale specific tags/functions with SetLocale function as following.

<cfscript>
    /*
        Setting required locale
        tr_TR used for Turkish
    */
    SetLocale("tr_TR");
</cfscript>

It will allow us to use formatting in defined locale as following.

<cfscript>
    /*
        Setting required locale
        tr_TR used for Turkish
    */
    SetLocale("tr_TR");
   
       /* Defining custom parameters */
    myTime = Now();
    myDateFormat = "DD MMMM YYYY, DDDD";   
</cfscript>

<cfoutput>
    #LSDateFormat(myTime,myDateFormat)#
</cfoutput>


All available locales which are supported in ColdFusion can be accessible on the "server.coldfusion.supportedlocales" list dump.


+
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. Permissions beyond the scope of this license, pertaining to the examples of code included within this work are available at Adobe.

Report abuse

Related recipes