Java BigDecimal PackUnit2Uom(BigDecimal packUit, String eachUnitName)

Here you can find the source of PackUnit2Uom(BigDecimal packUit, String eachUnitName)

Description

Pack Unit Uom

License

Apache License

Declaration

public static String PackUnit2Uom(BigDecimal packUit, String eachUnitName) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.math.BigDecimal;

public class Main {
    public static String PackUnit2Uom(BigDecimal packUit, String eachUnitName) {
        if (eachUnitName.compareTo("EA") == 0) {
            //            if(packUit.intValue()>100){
            //                return String.format("S%02d", packUit.intValue()/10);
            //            }
            return String.format("H%02d", packUit.intValue());
        } else if (eachUnitName.compareTo("KG") == 0) {
            return String.format("H%.4fK", packUit.floatValue());
        } else if (eachUnitName.compareTo("G") == 0) {
            return String.format("H%.4fG", packUit.floatValue());
        } else {// w  ww  .  j a v  a 2  s  . co  m
            return String.format("H%.4fN", packUit.floatValue());
        }
    }
}

Related

  1. numberToWordsWithDecimal(BigDecimal value)
  2. nvl(final BigDecimal bigDecimal)
  3. nvlZero(BigDecimal num)
  4. objectToBigDecimal(Object object)
  5. objToBigDecimal(Object obj)
  6. percent0(final BigDecimal c, final BigDecimal percent)
  7. percentage(BigDecimal bd)
  8. percentChange(BigDecimal oldValue, BigDecimal newValue)
  9. percentOf(BigDecimal fullAmount, int percentToKeep)