All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.ztemplates.property.ZBigDecimalProperty Maven / Gradle / Ivy

Go to download

java web framework - annotations - pojo - NO XML - state-free - clean, technology agnostic urls - REST - invisible to the web-client - JSP, Velocity, FreeMarker (others pluggable) - annotations for JavaScript/CSS dependencies - create reusable components

The newest version!
/*
 * 11.12.2005
 * @author www.gerdziegler.de
 */
package org.ztemplates.property;

import java.math.BigDecimal;

public class ZBigDecimalProperty extends ZProperty
{
  private int scale = -1;

  private int roundingMode = BigDecimal.ROUND_HALF_UP;


  public ZBigDecimalProperty()
  {
  }


  public ZBigDecimalProperty(int scale, int roundingMode)
  {
    this.scale = scale;
    this.roundingMode = roundingMode;
  }


  public ZBigDecimalProperty(BigDecimal val)
  {
    setValue(val);
  }


  public BigDecimal parse(String formattedValue) throws Exception
  {
    BigDecimal i = new BigDecimal(formattedValue);
    if (scale >= 0)
    {
      i.setScale(scale, roundingMode);
    }
    return i;
  }


  public String format(BigDecimal obj)
  {
    return obj == null ? null : obj.toString();
  }


  public int getScale()
  {
    return scale;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy