Jump to content
We've recently updated our Privacy Statement, available here ×

expression and division


tadan

Recommended Posts

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

1) You can do it in your source query:

 

 

SELECT FIELDNAME/100 as FIELDNAME

FROM SOMEWHERE

 

 

and set you TextField Expression to be simply $F{FIELDNAME}.

 

 

or

 

 

2) you can do it your report TextField by setting the TextField Expression to something like new java.lang.Double($F{FIELDNAME}.doubleValue()/100)

 

 

Either way you will need the TextField to be defined as a java.lang.Double or java.math.BigDecimal, depending on the size of your data.

 

 

You can set the output format using a variation on the "#,##0.00" format string. For example, "#,##0" will display integer values.

 

 

Have fun.

Link to comment
Share on other sites

Hi

many thanks for you're response.

If I try to follow the 2nd way, when I compile the report appairs an error that says:

"the method DoubleValue() is undefined for the type Integer".

I think this is referred to my field that is an integer but I'm not sure ... could you give me more help?

Many thanks

 

all the best

 

Francesco

Link to comment
Share on other sites

You problem is that java is case sensitive: use doubleValue() not DoubleValue().

 

 

 

If your field is an Integer then you can always grab its intValue(), like this:

 

 

new java.lang.Double($F{FIELDNAME}.intValue()/100)

 

 

You TextField is still a java.lang.Double. You can force it to be a java.lang.Integer if you want, just recast the result like this:

 

 

new java.lang.Integer(new java.lang.Double($F{FIELDNAME}.intValue()/100).intValue())

 

 

 

.

Post edited by: jmurray, at: 2007/10/11 22:43

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...