Here you can find the source of PackUnit2Uom(BigDecimal packUit, String eachUnitName)
public static String PackUnit2Uom(BigDecimal packUit, String eachUnitName)
//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()); } } }