1 package org.kuali.ole.sys.businessobject.format;
2
3 import java.math.BigDecimal;
4
5 import org.apache.log4j.Logger;
6 import org.kuali.rice.core.api.util.type.KualiDecimal;
7 import org.kuali.rice.core.web.format.BigDecimalFormatter;
8
9
10
11
12
13 public class ExplicitKualiDecimalFormatter extends BigDecimalFormatter {
14 private static Logger LOG = Logger.getLogger(ExplicitKualiDecimalFormatter.class);
15
16
17
18
19 @Override
20 protected Object convertToObject(String target) {
21 BigDecimal value = (BigDecimal)super.convertToObject(addDecimalPoint(target));
22 return new KualiDecimal(value);
23 }
24
25
26
27
28
29
30 private String addDecimalPoint (String amount) {
31 if (!amount.contains(".")) {
32 int length = amount.length();
33 amount = amount.substring(0, length - 2) + "." + amount.substring(length - 2, length);
34 }
35 return amount;
36 }
37 }