2 Replies Latest reply on Dec 6, 2006 4:09 AM by

    Error converting CF int to JAVA long

      Hi,
      I am calling a java method in my code that expects a parameter of type long (64 bit).
      If I pass a large int from ColdFusion (i.e. 10000000000) I get the following error:

      Could not convert the value 1.0E10 to an integer because it cannot fit inside an integer.

      I understand that CF integers are 32 bit so I tried to use the javacast function as follows:

      TestPaymentVO.setTestAmount(javacast("long", form.testAmt);

      but I still get the same error.

      Is there ANY way past this????
      Any help would be much apprecieated.
      Thanks.
        • 1. Error converting CF int to JAVA long
          Stefan_K.
          Ran into the JavaCast-long problem a while ago & then wrote the following article:

          http://kuhn.cf-workshop.de/CF_BUGS/JavaCast_long.htm

          Don't really see a general solution though, my solutions were either to call another function (int-input) or write pieces of code in java to handle the long-datatype there.
          For ex. a java-function reveiving a string, converting the string to java-long, then calling the desired java-function.
          1 person found this helpful
          • 2. Re: Error converting CF int to JAVA long
            Okay, I seem to have found a solution to this....
            In Coldfusion create a java object of type java.lang.Long and call its init() method.
            Then when you are passing it to java call its .longValue() method
            For example:

            <cfset amt = CreateObject( "Java", "java.lang.Long" ).init(form.bonusAmt)/>
            ....
            PaymentVO.setAmount(amt .longValue());
            ......