当前位置:网站首页>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: 谁说写中国风 一定要商角徵羽宫
边栏推荐
- excel函数统计已存在数据的数量
- From starfish OS' continued deflationary consumption of SFO, the value of SFO in the long run
- Vim 字符串替换
- Strive to ensure that domestic events should be held as much as possible, and the State General Administration of sports has made it clear that offline sports events should be resumed safely and order
- Common disk formats and the differences between them
- Spock单元测试框架介绍及在美团优选的实践_第三章(void无返回值方法mock方式)
- VR/AR 的产业发展与技术实现
- 常见的磁盘格式以及它们之间的区别
- Introduction to QT: video player
- Learn CV two loss function from scratch (4)
猜你喜欢

JVM memory and garbage collection -4-string

关于TXE和TC标志位的小知识

Clickhouse principle analysis and application practice "reading notes (8)

XMeter Newsletter 2022-06|企业版 v3.2.3 发布,错误日志与测试报告图表优化

JVM memory and garbage collection-3-runtime data area / heap area

牛熊周期与加密的未来如何演变?看看红杉资本怎么说

Dnn+yolo+flask reasoning (raspberry pie real-time streaming - including Yolo family bucket Series)

mysql报错ORDER BY clause is not in SELECT list, references column ‘‘which is not in SELECT list解决方案

Discrimination gradient descent

Spock单元测试框架介绍及在美团优选的实践_第三章(void无返回值方法mock方式)
随机推荐
The generosity of a pot fish
力扣6_1342. 将数字变成 0 的操作次数
[reinforcement learning medical] deep reinforcement learning for clinical decision support: a brief overview
Spock单元测试框架介绍及在美团优选的实践_第三章(void无返回值方法mock方式)
LeetCode精选200道--链表篇
Learn CV two loss function from scratch (3)
电路如图,R1=2kΩ,R2=2kΩ,R3=4kΩ,Rf=4kΩ。求输出与输入关系表达式。
JVM memory and garbage collection -4-string
metasploit
Force buckle 5_ 876. Intermediate node of linked list
Anan's judgment
很多小伙伴不太了解ORM框架的底层原理,这不,冰河带你10分钟手撸一个极简版ORM框架(赶快收藏吧)
CV2 read video - and save image or video
[knowledge map] interpretable recommendation based on knowledge map through deep reinforcement learning
非分区表转换成分区表以及注意事项
JVM memory and garbage collection-3-runtime data area / method area
Can you write the software test questions?
[knowledge map paper] attnpath: integrate the graph attention mechanism into knowledge graph reasoning based on deep reinforcement
leetcode 865. Smallest Subtree with all the Deepest Nodes | 865.具有所有最深节点的最小子树(树的BFS,parent反向索引map)
Many friends don't know the underlying principle of ORM framework very well. No, glacier will take you 10 minutes to hand roll a minimalist ORM framework (collect it quickly)