Here you can find the source of intToString(int theValue, int nDigits)
Parameter | Description |
---|---|
theValue | the int to be converted. |
nDigits | the number of digits to return. |
public static String intToString(int theValue, int nDigits)
//package com.java2s; /*--------------------------------------------------------------- * Copyright 2005 by the Radiological Society of North America * * This source software is released under the terms of the * RSNA Public License (http://mirc.rsna.org/rsnapubliclicense) *----------------------------------------------------------------*/ public class Main { /**//from w ww .j a v a2 s. c o m * Convert a positive int to a String with at least n digits, * padding with leading zeroes. * @param theValue the int to be converted. * @param nDigits the number of digits to return. * @return the converted value. */ public static String intToString(int theValue, int nDigits) { String s = Integer.toString(theValue); int k = nDigits - s.length(); for (int i = 0; i < k; i++) s = "0" + s; return s; } }