EDITED to add the full code block in case the error is ME and my rusty coding and not the version of Open JDK.
<!--- for discussion purposes, the dollar amount is set via form submission --->
<cfset dollarAmount = "#form.dollarAmount#" />
<!--- check the formatting, append cents to any hanging decimal as a result
of user entry of non numeric characters (yes this happened). 'dollarAmount"
is parsed through a function to remove non numeric characters, but to still
allow a decimal, thus the possibility of a hanging decimal on the right --->
<cfif (#right(dollarAmount,1)# == ".")>
<cfset dollarAmount="#dollarAmount#" & "00" />
</cfif>
<!--- check the formatting again --->
<cfif (#dollarAmount# != "") AND (#isNumeric(dollarAmount)#)>
<cfset dollarAmount ="#numberFormat(dollarAmount, '0.00')#" />
</cfif>
Before upgrading to JDK 20 this was not an issue. I was running JDK 18 (IIR) before the upgrade.
The IF statement tested a dollar amount and, if after stripping non numeric characters, the remaining right most char was a decimal, then two 0âs were added to avoid an error encountered in previous JDK or Lucee or Railo versions.
This code snippet has been fine for years. But after upgrading to JDK 20, the result is that entering an amount without the cents (example: â20â vs â20.00â), results in two place values being added to the number. So, an entry of â20â becomes â2000.00â. However, if I enter 20.00, then that remains as 20.00.
Why would this change? How is the CFIF statement being evaluated now?
My solution is that I simply REMOVED the first IF statement and now things are working as expected:
<!--- check the formatting, append cents to any hanging decimal as a result of user entry
of non numeric characters (yes this happened): 8/10/23: this is not giving the expected
results after upgrade to Open JDK 20 - remove it
<cfif (#right(dollarAmount,1)# == ".")>
<cfset paymentTotal="#dollarAmount#" & "00" />
</cfif> --->
Ubuntu 22.04 LTS
Java (JDK) 20.0.2
Tomcat 9.0.41
Lucee 5.4.1.8