Java Long to String long2StringForLen(long num, String str)

Here you can find the source of long2StringForLen(long num, String str)

Description

long String For Len

License

Open Source License

Declaration

public static String long2StringForLen(long num, String str) 

Method Source Code

//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);
        }
    }
}

Related

  1. long2String(final long ip)
  2. Long2String(final long value)
  3. long2string(long lng, StringBuilder buff)
  4. long2string(long longdata)
  5. long2String(long x)
  6. long2Word(long val)
  7. LongToStr(long nValue)
  8. longToString(final long value)
  9. longToString(long l)