Here you can find the source of long2StringForLen(long num, String str)
public static String long2StringForLen(long num, String str)
//package com.java2s; /**// www . java 2 s . com * Copyright 2010 ZTEsoft Inc. All Rights Reserved. * * This software is the proprietary information of ZTEsoft Inc. * Use is subject to license terms. * * $Tracker List * * $TaskId: $ $Date: 9:24:36 AM (May 9, 2008) $comments: create * $TaskId: $ $Date: 3:56:36 PM (SEP 13, 2010) $comments: upgrade jvm to jvm1.5 * * */ public class Main { public static String long2StringForLen(long num, String str) { int len = String.valueOf(num).length(); if (len > str.length()) { return String.valueOf(num).substring(len - str.length(), len); } else { return str.substring(0, str.length() - len) + String.valueOf(num); } } }