Here you can find the source of formatNumberWithZeroPrefix(int numOfZero, Integer value)
Parameter | Description |
---|---|
numOfZero | Num of Zero for the integer as prefix |
value | The target value to be format |
public static String formatNumberWithZeroPrefix(int numOfZero, Integer value)
//package com.java2s; /*/*from w w w. j a va 2s.c o m*/ * @(#)TextUtility.java * * Copyright (c) 2003 DCIVision Ltd * All rights reserved. * * This software is the confidential and proprietary information of DCIVision * Ltd ("Confidential Information"). You shall not disclose such Confidential * Information and shall use it only in accordance with the terms of the license * agreement you entered into with DCIVision Ltd. */ import java.text.NumberFormat; public class Main { /** * formatNumberWithZeroPrefix * * Convert a integer (java.sql.Integer) representation into string with Zeros prefix. * * @param numOfZero Num of Zero for the integer as prefix * @param value The target value to be format * @return String The String format after convertion */ public static String formatNumberWithZeroPrefix(int numOfZero, Integer value) { return (formatNumberWithZeroPrefix(numOfZero, value, false)); } /** * formatNumberWithZeroPrefix * * Convert a integer (java.sql.Integer) representation into string with Zeros prefix. * * @param numOfZero Num of Zero for the integer as prefix * @param value The target value to be format * @param grouping Property of having the ',' format; true for "10, 000", false for "10000" * @return String The String format after convertion */ public static String formatNumberWithZeroPrefix(int numOfZero, Integer value, boolean grouping) { NumberFormat df = NumberFormat.getInstance(); df.setGroupingUsed(grouping); df.setMinimumIntegerDigits(numOfZero); return (df.format(value)); } }