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
| package com.zhitan.common.utils;
|
| /**
| * @Description: 整数相关工具类
| * @author ZhiTan
| * @date: 2022年03月10日 17:31
| */
| public class IntegerUtil {
| /**
| * 字符串转成int类型
| *
| * @param str
| * @return
| */
| public static int toInt(String str) {
| int d = 0;
| try {
| d = Integer.parseInt(str);
| } catch (Exception e) {
| d = 0;
| }
| return d;
| }
|
| /**
| * long转成int类型
| *
| * @param l
| * @return
| */
| public static int toInt(long l) {
| int d = 0;
| try {
| d = (int) l;
| } catch (Exception e) {
| d = 0;
| }
| return d;
| }
| }
|
|