Java SQL Date Format formatNumberWithZeroPrefix(int numOfZero, Integer value)

Here you can find the source of formatNumberWithZeroPrefix(int numOfZero, Integer value)

Description

formatNumberWithZeroPrefix Convert a integer (java.sql.Integer) representation into string with Zeros prefix.

License

Open Source License

Parameter

Parameter Description
numOfZero Num of Zero for the integer as prefix
value The target value to be format

Return

String The String format after convertion

Declaration

public static String formatNumberWithZeroPrefix(int numOfZero, Integer value) 

Method Source Code

//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));
    }
}

Related

  1. formatDateTd(Object obj)
  2. formatDateToCustfmt(java.util.Date date, String dateFmt)
  3. formatDurationMillisToString(long millis)
  4. formatFloat(int floatValue)
  5. formatLogParam(Array obj)
  6. formatSQLError(SQLException e)
  7. formatSqlException( StringBuilder errorMessage, SQLException exception)
  8. formatSQLForColumnName(Connection conn, String strSQL)