• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Error converting CF int to JAVA long

Guest
Dec 04, 2006 Dec 04, 2006

Copy link to clipboard

Copied

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.
TOPICS
Advanced techniques

Views

451

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Dec 06, 2006 Dec 06, 2006
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());
......

Votes

Translate

Translate
Explorer ,
Dec 04, 2006 Dec 04, 2006

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Dec 06, 2006 Dec 06, 2006

Copy link to clipboard

Copied

LATEST
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());
......

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation