Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {

    private static String convertBase62ToDecimal(String ident62) {
        Long decimal = 0L;
        int base = 62;
        Long keisu = 0L;
        int cnt = 0;

        byte ident[] = ident62.getBytes();
        for (int i = ident.length - 1; i >= 0; i--) {
            int num = 0;
            if (ident[i] > 48 && ident[i] <= 57) {
                num = ident[i] - 48;
            } else if (ident[i] >= 65 && ident[i] <= 90) {
                num = ident[i] - 65 + 10;
            } else if (ident[i] >= 97 && ident[i] <= 122) {
                num = ident[i] - 97 + 10 + 26;
            }
            keisu = Math.round(java.lang.Math.pow((double) base, (double) cnt));
            decimal += num * keisu;
            cnt++;
        }
        return String.format("%08d", decimal);
    }
}