Here you can find the source of toBase36(long decimalNumber)
Parameter | Description |
---|---|
decimalNumber | a parameter |
public static String toBase36(long decimalNumber)
//package com.java2s; public class Main { private static final String baseDigits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; /**/* ww w .jav a2 s .c om*/ * Converts a given decimal value into its Base36 equivalent. * @param decimalNumber * @return */ public static String toBase36(long decimalNumber) { return fromDecimalToOtherBase(36, decimalNumber); } /** * Converts a decimal number to another counting system. * @param base the counting system to convert the the number to. * @param decimalNumber the input number to be converted * @return the converted number */ private static String fromDecimalToOtherBase(long base, long decimalNumber) { String tempVal = decimalNumber == 0 ? "0" : ""; long mod; while (decimalNumber != 0) { mod = decimalNumber % base; tempVal = baseDigits.substring((int) mod, (int) (mod + 1)) + tempVal; decimalNumber = decimalNumber / base; } return tempVal; } }