Java Unsigned Number Create unsignedZerofill(Integer number, int offset)

Here you can find the source of unsignedZerofill(Integer number, int offset)

Description

Converts an integer to a unsigned zerofill representation specified by the given offset.

License

Open Source License

Parameter

Parameter Description
number The integer number to be converted into a zerofill representation
offset The offset of the zerofill representation

Return

Zerofill representation of the given integer number

Declaration

public static String unsignedZerofill(Integer number, int offset) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/*w  w  w .j  a v  a 2  s .  com*/
     * Converts an integer to a unsigned zerofill representation specified by the given offset. 
     * E.g. Int(1)/Offset 4 will be converted to String(0001)
     * 
     * @param number The integer number to be converted into a zerofill representation
     * @param offset The offset of the zerofill representation
     * @return Zerofill representation of the given integer number
     */
    public static String unsignedZerofill(Integer number, int offset) {
        String result = "";

        while (result.length() < (offset - number.toString().length())) {
            result += "0";
        }

        return result + number.toString();
    }
}

Related

  1. unsignedToSigned8(char value)
  2. unsignedUnion2by2(final short[] set1, final int length1, final short[] set2, final int length2, final short[] buffer)
  3. unsignedUpcast(short s)
  4. unsignedValue(byte signedByte)
  5. unsignedVLQSize(int value)
  6. unsignL(byte value)