Write code to pad long with 0 on the right and return a String
//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 ww w .j ava 2s . c om 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; } }