Here you can find the source of toBase10(final String base62)
Parameter | Description |
---|---|
base62 | number |
public static Long toBase10(final String base62)
//package com.java2s; /**//from w w w . j a v a2 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 base62 * number * @return converted number into Base10 */ public static Long toBase10(final String base62) { return toBase10(new StringBuilder(base62).reverse().toString().toCharArray()); } private static Long toBase10(final char[] chars) { long base10 = 0L; for (int i = chars.length - 1; i >= 0; i--) { base10 += toBase10(BASE62_ALPHABET.indexOf(chars[i]), i); } return base10; } private static int toBase10(final int n, final int pow) { return n * (int) Math.pow(BASE62_BASE, pow); } }