Java - Write code to pad long with 0 on the right and return a String

Requirements

Write code to pad long with 0 on the right and return a String

Demo

//package com.book2s;
import java.text.DecimalFormat;

public class Main {
    public static void main(String[] argv) {
        long val = 42;
        int len = 42;
        System.out.println(long2StringRightBlank(val, len));
    }/*from  w  w w  .  j  ava 2s  . c  o  m*/

    public static String long2StringRightBlank(long val, int len) {
        String pattern = "#";
        DecimalFormat fmt = new DecimalFormat(pattern);
        String str = fmt.format(val);
        if (str.length() < len) {
            return str + FillString(' ', len - str.length());
        } else
            return str.substring(str.length() - len);
    }

    public static String FillString(char val, int len) {
        String str = "";
        for (int i = 0; i < len; i++)
            str = str + val;
        return str;
    }
}