michael.edstrom1 Posted March 3, 2017 Share Posted March 3, 2017 So, I'm currently working on a report in iReport 5.6.0.I'm having a problem with a calculation in a textfield.Language in file: Groovy.Variable = java.lang.DoubleSo I'm getting the price of a product from a field, we can call it: $F{x_x}, this field is a string, but contains only numbers(double) like this, "540,00".What I wan't to do now is first get some code to check for empty fields or nulls, which I do like this: ($F{x_x} == null || $F{x_x} == " ") ? "" : <--- so far so good.What needs to happen now is to take the string that's inside the field(if you pass the first statement) and make this string into a number(double I assume) and then divide it with 0,9.I've found some possible solutions for this in other threads and also tried some of my own but it just doesn't want to work. I just get errors regarding that specific code won't work(in iReport), and the pdf won't open obviously.Suggestions on a solution for this? Thanks in advance. Link to comment Share on other sites More sharing options...
hozawa Posted March 3, 2017 Share Posted March 3, 2017 Try the following:$F{column1}==null||$F{column1}.length()<1?"":(Double.parseDouble($F{column1})/0.9) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now