Java File Size Readable Format formatarNumeroComZerosAEsquerda(long numero, int size)

Here you can find the source of formatarNumeroComZerosAEsquerda(long numero, int size)

Description

formatar Numero Com Zeros A Esquerda

License

Apache License

Declaration

public static String formatarNumeroComZerosAEsquerda(long numero, int size) 

Method Source Code

//package com.java2s;
/*/*from  ww  w  . j  av  a  2  s.c  o m*/
 *   fan.tools - small tools in java/gwt 
 *   Copyright (C) 2011  Fabio Almeida (http://fabioalmeida.net)
 *
 * 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 {
    public static String formatarNumeroComZerosAEsquerda(long numero, int size) {
        String result = String.valueOf(numero);
        while (result.length() < size) {
            result = "0" + result;
        }
        return result;
    }
}

Related

  1. convertFileSize(double size, Locale locale)
  2. convertFileSize(long size)
  3. convertFileSize(long size)
  4. formatByteSize(long bytes, int decimals)
  5. formatByteSize(long bytes, int lastDigits)
  6. formatByteSize(long byteSize)
  7. formatByteSizeToString(long bytes)