当前位置:网站首页>hutool工具类的使用,国内自己封装的工具包,挺好用的
hutool工具类的使用,国内自己封装的工具包,挺好用的
2022-07-08 01:13:00 【时间是一种解药】
hutool工具类的使用,国内自己封装的工具包,挺好用的
问题背景
无意之中,别人推荐使用的工具包,确实很方便,这里贴一些自己常用的方法,其他需求可以去官网查看
注意事项:
- hutool官网:https://www.hutool.cn
- 中文参考文档:https://www.hutool.cn/docs/#/
- 使用hutool的优势
Hutool工具包的使用
1 导入依赖
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.4</version>
</dependency>
2 转为字符串
int a = 1;
//aStr为"1"
String aStr = Convert.toStr(a);
long[] b = {
1,2,3,4,5};
//bStr为:"[1, 2, 3, 4, 5]"
String bStr = Convert.toStr(b);
3 转为指定类型数组
String[] b = {
"1", "2", "3", "4" };
//结果为Integer数组
Integer[] intArray = Convert.toIntArray(b);
long[] c = {
1,2,3,4,5};
//结果为Integer数组
Integer[] intArray2 = Convert.toIntArray(c);
4 转为日期对象
String a = "2017-05-06";
Date value = Convert.toDate(a);
5 转为集合
Object[] a = {
"a", "你", "好", "", 1};
List<?> list = Convert.toList(a);
6 生成UUID
//生成的UUID是带-的字符串,类似于:a5c8a5e8-df2b-4706-bea4-08d0939410e3
String uuid = IdUtil.randomUUID();
//生成的是不带-的字符串,类似于:b17f24ff026d40949c85a24f4f375d42
String simpleUUID = IdUtil.simpleUUID();
7 数组判断是否为空
int[] a = {
};
int[] b = null;
ArrayUtil.isEmpty(a);
ArrayUtil.isEmpty(b);
总结
用什么,补什么
作为程序员第 196 篇文章,每次写一句歌词记录一下,看看人生有几首歌的时间,wahahaha …
Lyric: 谁说写中国风 一定要商角徵羽宫
边栏推荐
- LeetCode精选200道--链表篇
- 如何用Diffusion models做interpolation插值任务?——原理解析和代码实战
- PHP calculates personal income tax
- 【每日一题】648. 单词替换
- Learn CV two loss function from scratch (4)
- Key points of data link layer and network layer protocol
- [knowledge map paper] Devine: a generative anti imitation learning framework for knowledge map reasoning
- Dnn+yolo+flask reasoning (raspberry pie real-time streaming - including Yolo family bucket Series)
- Talk about the cloud deployment of local projects created by SAP IRPA studio
- 科普 | 什么是灵魂绑定代币SBT?有何价值?
猜你喜欢
常见的磁盘格式以及它们之间的区别
"Hands on learning in depth" Chapter 2 - preparatory knowledge_ 2.2 data preprocessing_ Learning thinking and exercise answers
Towards an endless language learning framework
Disk rust -- add a log to the program
谈谈 SAP iRPA Studio 创建的本地项目的云端部署问题
入侵检测——jsql
How does the bull bear cycle and encryption evolve in the future? Look at Sequoia Capital
UFS Power Management 介绍
Spock单元测试框架介绍及在美团优选的实践_第三章(void无返回值方法mock方式)
XMeter Newsletter 2022-06|企业版 v3.2.3 发布,错误日志与测试报告图表优化
随机推荐
【每日一题】736. Lisp 语法解析
Introduction to Microsoft ad super Foundation
Force buckle 6_ 1342. Number of operations to change a number to 0
很多小伙伴不太了解ORM框架的底层原理,这不,冰河带你10分钟手撸一个极简版ORM框架(赶快收藏吧)
科普 | 什么是灵魂绑定代币SBT?有何价值?
Yolo fast+dnn+flask realizes streaming and streaming on mobile terminals and displays them on the web
cv2-drawline
Ml self realization / linear regression / multivariable
Leetcode featured 200 -- linked list
入侵检测——Uniscan
Completion report of communication software development and Application
Monthly observation of internet medical field in May 2022
In the digital transformation of the financial industry, the integration of business and technology needs to go through three stages
JVM memory and garbage collection-3-object instantiation and memory layout
Industrial Development and technological realization of vr/ar
[recommendation system paper reading] recommendation simulation user feedback based on Reinforcement Learning
#797div3 A---C
阿锅鱼的大度
Talk about the realization of authority control and transaction record function of SAP system
[knowledge map] interpretable recommendation based on knowledge map through deep reinforcement learning