Java Integer Format format(int num, int length)

Here you can find the source of format(int num, int length)

Description

format

License

Apache License

Declaration

public static String format(int num, int length) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static String format(String str, int length) {
        while (str.length() > length)
            length++;//from  ww  w. j  ava2 s  . co  m
        while (str.length() < length) {
            str = "0" + str;
        }
        return str;
    }

    public static String format(int num, int length) {
        String str = Integer.toHexString(num);
        return format(str, length);
    }
}

Related

  1. format(int color)
  2. format(int i, int fillLength)
  3. format(int i, int length, boolean left_justify, char fill)
  4. format(int intval)
  5. format(int num)
  6. format(int spaces, String string)
  7. format(int ticks)
  8. formatInt(int i, int radix, int len)
  9. formatInt(int in, int precision)