DateFormat function in ColdFusion (2021 release)

Problem

In Adobe ColdFusion (2021 release), the mask D in date formatting functions, such as, DateFormat has been fixed to return the day of year. Since this can cause a few backward-compatibility issues, we've added a flag in jvm.config, the details of which are explained below.

For more information on this behavior, see the following:

Solution

We've added a JVM flag -Dcoldfusion.datemask.useDasdayofmonth. It defaults to false but when set to true and the mask contains D (uppercase D), the mask treats the value as d (lowercase d), day of the month. Hence, dateformat(now(), "mm-D-yyyy") is the same as dateformat(now(), "mm-d-yyyy") when flag is set to true. By default, an uppercase D is used to specify Day of the year. 

For example, if the flag is set to False, and you run the snippet below, you get the following output.

<cfscript> 
    writeOutput(dateformat(now(), "mm-D-yyyy") & "<br/>") 
    writeOutput(dateformat(now(), "mm-DD-yyyy") & "<br/>") 
</cfscript>

OUTPUT

12-337-2020
12-337-2020

The uppercase D represents the day as the number of the day in the year (out of 365).

If the flag is set to True, and you run the snippet below, you get the following output.

<cfscript> 
    writeOutput(dateformat(now(), "mm-D-yyyy") & "<br/>") 
    writeOutput(dateformat(now(), "mm-DD-yyyy") & "<br/>") 
</cfscript>

OUTPUT

12-2-2020
12-2-2020

Apply the fix

  1. 다운로드

    Copy the jar file in CF_HOME/cfusion/lib/updates.

  2. In the jvm.config file (CF_HOME/cfusion/bin), set the flag below to True. The default value if False.

    -Dcoldfusion.datemask.useDasdayofmonth=true

  3. Restart ColdFusion.

  4. Verify that the jar is updated. In the ColdFusion Administrator, in Settings Summary, look up the jar in the section CF Server Java Class Path.

 Adobe

쉽고 빠르게 지원 받기

신규 사용자이신가요?