Java Long to Base longToBase36(long decimalNumber)

Here you can find the source of longToBase36(long decimalNumber)

Description

Converts a long to base 36.

License

Open Source License

Parameter

Parameter Description
decimalNumber a parameter

Declaration

public static String longToBase36(long decimalNumber) 

Method Source Code

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

public class Main {
    private static final String DIGITS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";

    /**/*from w w  w.j  a  v  a 2  s . c  o  m*/
     * Converts a long to base 36.
     * @param decimalNumber
     * @return
     */
    public static String longToBase36(long decimalNumber) {
        long base = 36;
        String tempVal = decimalNumber == 0 ? "0" : "";
        int mod = 0;

        while (decimalNumber != 0) {
            long m = decimalNumber % base;
            mod = (int) m;
            tempVal = DIGITS.substring(mod, mod + 1) + tempVal;
            decimalNumber = decimalNumber / base;
        }

        return tempVal;
    }
}

Related

  1. longToBase36(long in)
  2. longToBase64(long number)