2001 JI Open Discussion Posted August 17, 2006 Share Posted August 17, 2006 By: elis - pelis Formatting a number with pattern 2002-12-09 12:13I want to display a field from my database. I get the field from database as a String. Actually the field is a number (Integer). I want to display the field with the pattern "00000" meaning that I want to display leading 0's if the field has less than five digits. I could use pattern="00000" in a <textField> in the report but 'pattern' and display the field as an Integer but the problem is that I don't want to display anything when I get a null value from the database. Can I do the formatting in a variable that I define for the field that I want to display? By: elis - pelis RE: Formatting a number with pattern 2002-12-09 12:30I found the solution for my problem. I defined a variable for my field and formatted the number as follows: ((new DecimalFormat("00000")).format(Integer.valueOf($F{TRANSIT}))).toString() By: elis - pelis RE: Formatting a number with pattern 2002-12-09 12:31I found the solution for my problem. I defined a variable for my field and formatted the number as follows: ((new DecimalFormat("00000")).format(Integer.valueOf($F{TRANSIT}))).toString() 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