Hutool常见使用的类

1、类型转换工具类-Convert

int a = 1;
//aStr为"1"
String aStr = Convert.toStr(a);
2、日期时间工具类
DateTime
Date date = DateUtil.date();
3、文本读取-FileReader
FileReader fileReader = new FileReader("test.properties");
String result = fileReader.readString();
文本写入-FileWriter
FileWriter writer = new FileWriter("test.properties");
writer.write("test");
 文件名工具类-FileNameUtil
File file = FileUtil.file("/opt/test.txt");
// test.txt
String name = FileNameUtil.getName(file);
4、随机工具-RandomUtil
int c = RandomUtil.randomInt(10, 100);
5、唯一Id工具-IdUtil
//生成的UUID是带-的字符串,类似于:a5c8a5e8-df2b-4706-bea4-08d0939410e3
String uuid = IdUtil.randomUUID();
//生成的是不带-的字符串,类似于:b17f24ff026d40949c85a24f4f375d42
String simpleUUID = IdUtil.simpleUUID();
雪花算法Id
//参数1为终端ID
//参数2为数据中心ID
Snowflake snowflake = IdUtil.getSnowflake(1, 1);
long id = snowflake.nextId();
//简单使用
long id = IdUtil.getSnowflakeNextId();
String id = snowflake.getSnowflakeNextIdStr();
6、字符串工具类-StrUtil
7、Bean工具-BeanUtil 
Bean转Map
SubPerson person = new SubPerson();
person.setAge(14);
person.setOpenid("11213232");
person.setName("测试A11");
person.setSubName("sub名字");
 
Map<String, Object> map = BeanUtil.beanToMap(person);
具体的查看官网

Hutool官网https://www.hutool.cn/docs/#/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值