Java String Pad Left leftPadZeros(int value, int digits, StringBuilder sb)

Here you can find the source of leftPadZeros(int value, int digits, StringBuilder sb)

Description

left Pad Zeros

License

Apache License

Declaration

private static void leftPadZeros(int value, int digits, StringBuilder sb) 

Method Source Code

//package com.java2s;
/*//from   ww w .  j a  va 2  s. c o m
 *      Copyright (C) 2012-2015 DataStax Inc.
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */

public class Main {
    private static void leftPadZeros(int value, int digits, StringBuilder sb) {
        sb.append(String.format("%0" + digits + "d", value));
    }
}

Related

  1. leftPadInt(int number, int width)
  2. leftPadMultiline(String input, char padChar, int padWidth)
  3. leftPadString(String str, char pad, int length)
  4. leftPadString(String sValue, int iLength, String sPadString)
  5. leftPadWithZeros(String input, int expectedSize)
  6. leftZeroPad(String s)
  7. leftZeroPadding(int number, int howManyChar)
  8. lpad(final String input, final String padCode, final int toLength)
  9. lpad(final String s, final String pad, final int size)