ktrinad Posted August 31, 2006 Share Posted August 31, 2006 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 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