on ‎2018 Mar 08 1:55 PM
Hi,
I have used new attributes which have BigDecimal type. i tried to limit value to 2 decimal places but in backoffice its value is coming with multiple zeroes. How to Limit that value in backoffice.
<persistence type="property">
<columntype>
<value>java.math.BigDecimal</value>
</columntype>
</persistence>
<modifiers read="true" write="true" search="true" />
<defaultvalue>Double.valueOf(0.0d)</defaultvalue>
</attribute>
Request clarification before answering.
Hi ,
my persistence attribute helped me in limitation:
<columntype>
<value>java.math.BigDecimal</value>
</columntype>
</persistence>
<modifiers read="true" write="true" search="true" />
<defaultvalue>Double.valueOf(0.0d)</defaultvalue>
</attribute>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sachin,
You can create a custom interceptor that runs before saving the model. The Interceptor creation and example usages can be found here: https://help.hybris.com/6.6.0/hcd/8bfbf43e8669101480d0f060d79b1baa.html
In that interceptor you will have to write something like this to limit the decimal spaces
BigDecimal value = new BigDecimal(2.123456d);
System.out.println(value); //Prints 2.1345600000...
value = value.setScale(2, RoundingMode.CEILING);
System.out.println(value); // Prints 2.13
Another possibility to achive that will be to use Dynamic Attributes as described here: https://help.hybris.com/6.6.0/hcd/8bb46096866910149208fae7c4ec7596.html
Best regards,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.