Here you can find the source of fromBase10(final long base10)
Parameter | Description |
---|---|
base10 | number |
public static String fromBase10(final long base10)
//package com.java2s; /**//www . j a v a 2 s. c o m * Copyright (c) 2015 Bosch Software Innovations GmbH and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ public class Main { private static final String BASE62_ALPHABET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; private static final int BASE62_BASE = BASE62_ALPHABET.length(); /** * @param base10 * number * @return converted number into Base62 ASCII string */ public static String fromBase10(final long base10) { if (base10 == 0) { return "0"; } long temp = base10; final StringBuilder sb = new StringBuilder(); while (temp > 0) { temp = fromBase10(temp, sb); } return sb.reverse().toString(); } private static Long fromBase10(final long base10, final StringBuilder sb) { final int rem = (int) (base10 % BASE62_BASE); sb.append(BASE62_ALPHABET.charAt(rem)); return base10 / BASE62_BASE; } }