Jump to content
Changes to the Jaspersoft community edition download ×

Formatting a number with pattern


Recommended Posts

By: elis - pelis

Formatting a number with pattern

2002-12-09 12:13

I 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:30

I 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:31

I 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

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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...