|
|
@ -3,11 +3,13 @@ package info.bukova.isspst.ui;
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
import java.text.DecimalFormat;
|
|
|
|
import java.text.DecimalFormat;
|
|
|
|
import java.text.ParseException;
|
|
|
|
import java.text.ParseException;
|
|
|
|
|
|
|
|
import java.util.Locale;
|
|
|
|
|
|
|
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.zkoss.bind.BindContext;
|
|
|
|
import org.zkoss.bind.BindContext;
|
|
|
|
import org.zkoss.bind.Converter;
|
|
|
|
import org.zkoss.bind.Converter;
|
|
|
|
|
|
|
|
import org.zkoss.util.Locales;
|
|
|
|
import org.zkoss.zk.ui.Component;
|
|
|
|
import org.zkoss.zk.ui.Component;
|
|
|
|
|
|
|
|
|
|
|
|
public class BigDecimalConverter implements Converter<String, BigDecimal, Component>
|
|
|
|
public class BigDecimalConverter implements Converter<String, BigDecimal, Component>
|
|
|
@ -23,7 +25,8 @@ public class BigDecimalConverter implements Converter<String, BigDecimal, Compon
|
|
|
|
{
|
|
|
|
{
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
DecimalFormat format = new DecimalFormat();
|
|
|
|
Locale loc = Locales.getCurrent();
|
|
|
|
|
|
|
|
DecimalFormat format = (DecimalFormat) DecimalFormat.getInstance(loc);
|
|
|
|
format.setParseBigDecimal(true);
|
|
|
|
format.setParseBigDecimal(true);
|
|
|
|
val = (BigDecimal) format.parse(str);
|
|
|
|
val = (BigDecimal) format.parse(str);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -43,6 +46,9 @@ public class BigDecimalConverter implements Converter<String, BigDecimal, Compon
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public String coerceToUi(BigDecimal val, Component component, BindContext cx)
|
|
|
|
public String coerceToUi(BigDecimal val, Component component, BindContext cx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
// String lang = Executions.getCurrent().getHeader("accept-language");
|
|
|
|
|
|
|
|
Locale loc = Locales.getCurrent();
|
|
|
|
|
|
|
|
|
|
|
|
if (val == null)
|
|
|
|
if (val == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
val = BigDecimal.ZERO;
|
|
|
|
val = BigDecimal.ZERO;
|
|
|
@ -50,13 +56,13 @@ public class BigDecimalConverter implements Converter<String, BigDecimal, Compon
|
|
|
|
|
|
|
|
|
|
|
|
val = val.setScale(2, BigDecimal.ROUND_DOWN);
|
|
|
|
val = val.setScale(2, BigDecimal.ROUND_DOWN);
|
|
|
|
|
|
|
|
|
|
|
|
DecimalFormat format = new DecimalFormat();
|
|
|
|
DecimalFormat format = (DecimalFormat) DecimalFormat.getInstance(loc);
|
|
|
|
format.setMaximumFractionDigits(2);
|
|
|
|
format.setMaximumFractionDigits(2);
|
|
|
|
format.setMinimumFractionDigits(2);
|
|
|
|
format.setMinimumFractionDigits(2);
|
|
|
|
format.setGroupingUsed(true);
|
|
|
|
format.setGroupingUsed(true);
|
|
|
|
format.setGroupingSize(3);
|
|
|
|
format.setGroupingSize(3);
|
|
|
|
|
|
|
|
String formatted = format.format(val);
|
|
|
|
return format.format(val);
|
|
|
|
return formatted;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|