0

我们面临一些错误 Java 方法安全异常。在“java.lang.Class”对象上调用 Java 方法时发生安全异常。方法名是 getName。可能的原因:在安全沙箱中禁用了 createobject 函数和 cfobject 标记,或者您尝试在 ColdFusion 包中创建一个类并且该类被禁用。

<cfset istTimezone = createObject( "java", "java.util.TimeZone" ).getTimeZone(javaCast( "string", "IST" ))/>
<cfset ISTCalendar = createObject( "java", "java.util.GregorianCalendar" ).init(istTimezone) />
<cfset ISTCalendar.setTimeInMillis(istCalendar.getTimeInMillis()) />
<cfset timespec = "GMT+0530 (India Standard Time)">
<cfset spacer = " ">
<cfinvoke component="cfc.timeZone" method="calendarToString" returnvariable="getDateC">
    <cfinvokeargument name="calendar" value="#istCalendar#"/> 
</cfinvoke>
<cfset Date=DateTimeFormat(getDateC,"EEE mmm dd yyyy hh:nn:ss")>
<cfset serverdate = Date & spacer & timespec>

timZone.cfc

<cffunction
    name="calendarToString"
    access="public"
    returntype="string"
    output="false"
    hint="I take a given instance of java.util.GregorianCalendar and return a readable date/time string.">
<cfargument name="calendar" type="any" required="true" hint="I am the Java calendar for which we 
       are creating a user-friendly date string."/>
<cfset var local = {} />
<cfset local.formatter = createObject( "java", "java.text.SimpleDateFormat" ).init(javaCast( "String", "MM/dd/yyyy h:mm aa" )) />
<cfset local.formatter.setTimeZone(arguments.calendar.getTimeZone()) />
<cfreturn local.formatter.format(arguments.calendar.getTime()) />
</cffunction>
4

0 回答 0