venu08 Posted July 1, 2011 Share Posted July 1, 2011 HiI have a problm on the field pattern .I can select the field pattern .In this we select the Number and chose the Decimal places is 5.When there is a data in table(database) its come in 2.23000 its ok ,but there is "0" zero in the table(database) its come in this formate 0.00000 but i want to show only 0(zero).but it has a data it can show 2.23000 formate . How can solve this problm i am not understand ThanksGvr Link to comment Share on other sites More sharing options...
cbarlow3 Posted July 1, 2011 Share Posted July 1, 2011 I can think of two ways to do it, although both methods involve setting up a condition to check whether or not the value is 0, and depending on what kind of math is involved in this particular field, you may end up still displaying some very small values as 0.00000.1. You could output a Text Field of type java.lang.String where the Text Field Expression is something like:$P{InputBigDecimal}==0 ?new DecimalFormat("#,##0").format($P{InputBigDecimal}):new DecimalFormat("#,##0.00000").format($P{InputBigDecimal})This uses the tertiary operator ?: to determine which pattern (DecimalFormat) to use, but it means that you have to specify the pattern directly in the expression rather than using the Pattern dropdown box. 2. You could create two fields, both of type BigDecimal, both of which have a Text Field Expression of simply $P{InputBigDecimal}, and both having exactly the same position on the report (they completely overlap). Make one of them have the dropdown pattern #,##0 while the other has the pattern #,##0.00000 (you specify five positions after the decimal). Then set up mutually exclusive Print When Conditions on these two fields: the first field would have a Print When Condition of $P{InputBigDecimal}==0, and the second field would have a Print When Condition of $P{InputBigDecimal} != 0. This method has the advantage of having simple expressions and using the dropdown to specify the pattern (also making it easier to remember how to do if you don't have examples at hand of the DecimalFormat syntax), but overuse of overlapping fields can make your design layout confusing.Hope one of those two methods works for your situation!Carl Link to comment Share on other sites More sharing options...
venu08 Posted July 2, 2011 Author Share Posted July 2, 2011 HiThanks for given Answare .I will try Thanksgvr 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