aspose file tools*
The moose likes Beginning Java and the fly likes converting bigdecimal Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "converting bigdecimal" Watch "converting bigdecimal" New topic
Author

converting bigdecimal

Tony Lavalle
Ranch Hand

Joined: Jan 18, 2005
Posts: 36
Here is what i am trying to do. I am using the jaspersoft iReport to help create reports, for am as400 the problem i have is this There is a field that is listed as a pack decimal 9 2. when i pull it into the iReport it turns it into a BigDecimal how do i convert this to a string of format it to a float or double?
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
Have you checked out the docs for BigDecimal?
Tony Lavalle
Ranch Hand

Joined: Jan 18, 2005
Posts: 36
yea, and for some reason they seem a little confusing

here is what i have for the variable

string charge = bigdecimal.tostring($f{@hatyp})
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
I'm not sure where you're getting that. There are methods floatValue(), intValue(), toString(), and toPlainString() that can give the float, int, String with scientific notation or without of a BigDecimal.
Tony Lavalle
Ranch Hand

Joined: Jan 18, 2005
Posts: 36
ok here is what i need it to like $244.39

i start with a packed decimal 9 2

in the ireports it comes in as a bigdecimal, and tells me to delete the token pointing at the field i brought in from the as400.
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Google results for "bigdecimal site:sun.com"
1st hit: http://java.sun.com/j2se/1.4.2/docs/api/java/math/BigDecimal.html

In the Javadoc you can find the available methods.
Tony Lavalle
Ranch Hand

Joined: Jan 18, 2005
Posts: 36
I have looked at those for some time today. here is where i am at.

$F{@HCHG$}.toPlainString()

the $f represents a field
the @HCHG$ is a packed decimal for a database on an as400

what am i missing?
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Hum ok, you want to decode a special packaged decimal into a bigdecimal?

Where exactly does it come from? Just straight out of DB2 on an AS/400?
[ October 17, 2006: Message edited by: Bauke Scholtz ]
Tony Lavalle
Ranch Hand

Joined: Jan 18, 2005
Posts: 36
yes, it comes from db2 on an as400.
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
I guess that this have to be done on the DAO or DB2 side. It have to uncompress/unpack the value before putting it in a Java object.
[ October 17, 2006: Message edited by: Bauke Scholtz ]
Tony Lavalle
Ranch Hand

Joined: Jan 18, 2005
Posts: 36
ook, so drive should i use i have the jt400, are there others.
 
 
subject: converting bigdecimal