Jump to content

Comparing String problem?


nitin403

Recommended Posts

Hi all,

I need to compare a string which is double value with zero.

And do some conditional print of value.

I tried searching and using them.

But always failed in doing so.

It is like this.

There is a string.

and I want to check that if it is greater then 0 then print one thing or else print something else.

This string can be like 1234.12 also.

 

Thanks for your help in advance.

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Hi,

Thanks for your reply.

 

Here is the case.

I have a field, let say

$F{UnusedCreditAmount} = "1234.12"

I need to display it in my report as red color when -ve and black when +ve

I know the code to print this field in Red.

 

I tried many combination but it always gives error message in IReport 2.0.5 while compling

Below is the error

Code:
he operator > is undefined for the argument 
type(s) Double, int value = (java.lang.String)(((new
Double(((java.lang.String)field_UnusedCreditAmount.getValue()))>0)

 

 

Thnaks for your help in advance

Link to comment
Share on other sites

hi,

I found the solution.

I used following code

 

Code:

(Float.parseFloat($F{UnusedCreditAmount})) < Float.parseFloat("0"«») ?
"<style forecolor='#ff0000'>" + $F{UnusedCreditAmount} + "</style>" :
$F{UnusedCreditAmount}
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...