Jump to content
JasperReports Library 7.0 is now available ×

formatting an integer


ktrinad

Recommended Posts

By: vivek srinivasan - viveksrinivasan

formatting an integer

2003-08-26 10:13

Hi,

My output form a report is 811. I want it in the format of 08/11. How can this be done?

Thx,

Vivek

 

 

 

 

By: Giulio Toffoli - gt78

RE: formatting an integer

2003-08-29 01:57

 

The output is every time of 3 or 4 numbers or could have 1 number only too ?

 

If your output is of 3 or 4 number every time you can use substring.... suppose your field is of type Integer and named mynum....

 

( ( $F{mynum}.intValue() > 999 ) (""+$F{mynum}).substring(0,2) + "/" + (""+ $F{mynum}).substring(3,4) : ("0"+$F{mynum}).substring(0,2) + "/" + (""+ $F{mynum}).substring(3,4) )

 

Set the type of the field to String.

If your number is greater that 9999 or lower than 100, you are fucked and an OutOfIndexException or a mistaked string will be throwed or printed.

 

Good Luck

 

Giulio

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