yangys
2024-03-29 410eed616ce86a76ecfbd272be0a4463ac54a517
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package com.qianwen.core.tool.utils;
 
import org.springframework.lang.Nullable;
import org.springframework.util.NumberUtils;
 
/* loaded from: blade-core-tool-9.3.0.0-SNAPSHOT.jar:org/springblade/core/tool/utils/NumberUtil.class */
public class NumberUtil extends NumberUtils {
    private static final char[] DIGITS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
 
    public static int toInt(final String str) {
        return toInt(str, -1);
    }
 
    public static int toInt(@Nullable final String str, final int defaultValue) {
        if (str == null) {
            return defaultValue;
        }
        try {
            return Integer.valueOf(str).intValue();
        } catch (NumberFormatException e) {
            return defaultValue;
        }
    }
 
    public static long toLong(final String str) {
        return toLong(str, 0L);
    }
 
    public static long toLong(@Nullable final String str, final long defaultValue) {
        if (str == null) {
            return defaultValue;
        }
        try {
            return Long.valueOf(str).longValue();
        } catch (NumberFormatException e) {
            return defaultValue;
        }
    }
 
    public static Double toDouble(String value) {
        return toDouble(value, null);
    }
 
    public static Double toDouble(@Nullable String value, Double defaultValue) {
        if (value != null) {
            return Double.valueOf(value.trim());
        }
        return defaultValue;
    }
 
    public static Float toFloat(String value) {
        return toFloat(value, null);
    }
 
    public static Float toFloat(@Nullable String value, Float defaultValue) {
        if (value != null) {
            return Float.valueOf(value.trim());
        }
        return defaultValue;
    }
 
    public static String to62String(long i) {
        int radix = DIGITS.length;
        char[] buf = new char[65];
        int charPos = 64;
        long j = -i;
        while (true) {
            long i2 = j;
            if (i2 <= (-radix)) {
                int i3 = charPos;
                charPos--;
                buf[i3] = DIGITS[(int) (-(i2 % radix))];
                j = i2 / radix;
            } else {
                buf[charPos] = DIGITS[(int) (-i2)];
                return new String(buf, charPos, 65 - charPos);
            }
        }
    }
}