Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

How to manipulate custom attributes of Decimal type?

Hi all,
Here is my doubt:

I have a workitem that contains custom attributes of Decimal type. These attributes are calculated and saved by a follow up plugin. In my code, this attributes are manipulated as BigDecimal.

One of the attributes is a financial value, but is showed in interface in the following format "1.834,4785"

I want to consider only two digits for cents, for example: 1.834,47.

So, how must I format the BigDecimal to save value in this format? Or how can I format the output field to show in this format? Can I format the output in a query result?

Thanks for help.

0 votes


Accepted answer

Permanent link
setScale(int newScale, RoundingMode roundingMode)
Returns a  BigDecimal  whose scale is the specified value, and whose unscaled value is determined by multiplying or dividing this  BigDecimal 's unscaled value by the appropriate power of ten to maintain its overall value.
You would need to use the int for scale and set it to 2. Then you can use the roundingMode to determine HALF_DOWN HALF_EVEN etc. I put a rounding mode link below
http://docs.oracle.com/javase/7/docs/api/java/math/RoundingMode.html

LUIZ DE ALMEIDA selected this answer as the correct answer

1 vote

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 12,019
× 10,936

Question asked: Oct 21 '14, 9:34 a.m.

Question was seen: 3,767 times

Last updated: Oct 23 '14, 2:50 p.m.

Confirmation Cancel Confirm