List of utility methods to do BigDecimal Format
String | formatRight(BigDecimal pNombre, NumberFormat pNf, int pMaxNumberOfDigit) format Right StringBuffer buf = new StringBuffer(); FieldPosition fpos = new FieldPosition(NumberFormat.INTEGER_FIELD); pNf.format(pNombre, buf, fpos); for (int i = 0; i < pMaxNumberOfDigit - fpos.getEndIndex(); ++i) { buf.insert(0, ' '); return buf.toString(); |
String | formatServiceSpecificDate(Date date) Formats the give date object into an KSC Service format. if (date == null) return null; BigDecimal dateValue = BigDecimal.valueOf(date.getTime()); return dateValue.scaleByPowerOfTen(0 - KSC_DATE_MILLI_SECOND_PRECISION).toPlainString(); |
String | formatSize(Integer size) format Size String formattedFileSize = ""; if (size != null) { BigDecimal kb = BigDecimal.valueOf(1024); BigDecimal mb = BigDecimal.valueOf(1048576); BigDecimal fileSizeBD = BigDecimal.valueOf(size); if (size > 999999) { formattedFileSize = fileSizeBD.divide(mb, 2, RoundingMode.HALF_UP).toPlainString(); formattedFileSize += " MB"; ... |
String | formatStore(long store) format Store if (store > TB) { double mem = divider(store, TB, 2); return new StringBuilder(String.valueOf(mem)).append(" ").append("TB").toString(); } else if (store > GB) { double mem = divider(store, GB, 2); return new StringBuilder(String.valueOf(mem)).append(" ").append("GB").toString(); } else if (store > MB) { double mem = divider(store, MB, 2); ... |
String | formattedFromBigDecimal(BigDecimal number, int scale, Locale locale) Convert from a BigDecimal forcing the scale. NumberFormat formatted = NumberFormat.getNumberInstance(locale);
formatted.setMaximumFractionDigits(scale);
formatted.setMinimumFractionDigits(scale);
return formatted.format(number.doubleValue());
|
BigDecimal | formattedToBigDecimal(String str, Locale locale) Convert to BigDecimal from a formatted string. if (str.length() == 0) { str = "0"; return new BigDecimal(NumberFormat.getNumberInstance(locale).parse(str).toString()); |
String | formatTime(BigDecimal seconds) format Time int whole = seconds.intValue(); BigDecimal frac = seconds.subtract(new BigDecimal(whole)); int f = frac.multiply(new BigDecimal(1000)).intValue(); int m = whole / 60; int s = whole % 60; int h = m / 60; m = m % 60; return String.format(TIME_FORMAT, h, m, s, f); ... |
float | formatTwoDecimals(float num) format Two Decimals BigDecimal bg = new BigDecimal(num); float f1 = bg.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue(); return f1; |
String | formatUnwithE(Object arg) DOC Administrator Comment method "formatUnwithE". String doubleString = String.valueOf(arg); int index = doubleString.indexOf("E"); if (index != -1) { return (new BigDecimal(doubleString)).toPlainString(); return doubleString; |
int | formatYuan2Fen(double fee) format Yuan Fen BigDecimal _fee = new BigDecimal(Double.toString(fee)); return _fee.multiply(new BigDecimal("100")).setScale(0, BigDecimal.ROUND_HALF_EVEN).intValue(); |