Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

converting bigdecimal

 
Tony Lavalle
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you checked out the docs for BigDecimal?
 
Tony Lavalle
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, it comes from db2 on an as400.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ook, so drive should i use i have the jt400, are there others.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic