Answered
CF2021 Issue with Java Date Object
Here's another issue I'm running into with our new CF2021 instance. This function worked fine with CF2016 using Java 11
public date function convertEpochToODBCDate( required numeric ts ){
var objTZ = createObject( "java", "java.util.TimeZone" );
var objDF = createObject( "java", "java.text.SimpleDateFormat" );
var objDate = createObject( "java", "java.util.Date" );
var dte = objDate.init( JavaCast("long",arguments.ts) * 1000 );
var tz = objTZ.getTimeZone( JavaCast("string", 'UTC') );
var outputFormat = objDF.init( javaCast( "string", "yyyy-MM-dd HH:mm:ss" ) );
outputFormat.setTimeZone(tz);
return CreateODBCDateTime( outputFormat.format(dte.getTime()) );
}
Here's the stack trace:
| Detail | Either there are no methods with the specified method name and argument types or the init method is overloaded with argument types that ColdFusion cannot decipher reliably. ColdFusion found 2 methods that match the provided arguments. If this is a Java object and you verified that the method exists, use the javacast function to reduce ambiguity. |
| Message | The init method was not found. |
| MethodName | init |
| StackTrace | coldfusion.runtime.java.MethodSelectionException: The init method was not found. at coldfusion.runtime.java.ObjectHandler.findConstructorUsingCFMLRules(ObjectHandler.java:496) at coldfusion.runtime.java.JavaProxy.CreateObject(JavaProxy.java:222) at coldfusion.runtime.java.JavaProxy.invoke(JavaProxy.java:89) at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:4254) at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:4217) |
