当前位置:网站首页>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: 谁说写中国风 一定要商角徵羽宫
边栏推荐
- internship:完成新功能增设接口
- 非分区表转换成分区表以及注意事项
- The bank needs to build the middle office capability of the intelligent customer service module to drive the upgrade of the whole scene intelligent customer service
- Applet running under the framework of fluent 3.0
- 线程死锁——死锁产生的条件
- Spock单元测试框架介绍及在美团优选的实践_第二章(static静态方法mock方式)
- Xmeter newsletter 2022-06 enterprise v3.2.3 release, error log and test report chart optimization
- PHP calculates personal income tax
- In depth analysis of ArrayList source code, from the most basic capacity expansion principle, to the magic iterator and fast fail mechanism, you have everything you want!!!
- Principle of least square method and matlab code implementation
猜你喜欢
Unity 射线与碰撞范围检测【踩坑记录】
[knowledge atlas paper] minerva: use reinforcement learning to infer paths in the knowledge base
Ml self realization / logistic regression / binary classification
leetcode 873. Length of Longest Fibonacci Subsequence | 873. 最长的斐波那契子序列的长度
Beaucoup d'enfants ne savent pas grand - chose sur le principe sous - jacent du cadre orm, non, ice River vous emmène 10 minutes à la main "un cadre orm minimaliste" (collectionnez - le maintenant)
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)
线程死锁——死锁产生的条件
很多小夥伴不太了解ORM框架的底層原理,這不,冰河帶你10分鐘手擼一個極簡版ORM框架(趕快收藏吧)
metasploit
Keras' deep learning practice -- gender classification based on inception V3
随机推荐
th:include的使用
Semantic segmentation | learning record (5) FCN network structure officially implemented by pytoch
Deeppath: a reinforcement learning method of knowledge graph reasoning
metasploit
Introduction to grpc for cloud native application development
WPF custom realistic wind radar chart control
Disk rust -- add a log to the program
实现前缀树
Xiaobai tutorial: Raspberry pie 3b+onnxruntime+scrfd+flask to realize public face detection system
Beaucoup d'enfants ne savent pas grand - chose sur le principe sous - jacent du cadre orm, non, ice River vous emmène 10 minutes à la main "un cadre orm minimaliste" (collectionnez - le maintenant)
COMSOL --- construction of micro resistance beam model --- final temperature distribution and deformation --- addition of materials
咋吃都不胖的朋友,Nature告诉你原因:是基因突变了
Leetcode featured 200 channels -- array article
Key points of data link layer and network layer protocol
leetcode 865. Smallest Subtree with all the Deepest Nodes | 865. The smallest subtree with all the deepest nodes (BFs of the tree, parent reverse index map)
金融业数字化转型中,业务和技术融合需要经历三个阶段
Opengl/webgl shader development getting started guide
#797div3 A---C
XMeter Newsletter 2022-06|企业版 v3.2.3 发布,错误日志与测试报告图表优化
直接加比较合适