首页 > 作文

hutool 工具类基本使用教程

更新时间:2023-04-03 23:53:19 阅读: 评论:0

在之前没有接触到这个工具类的时候,感觉自己好像根本就不知道这个的存在,再次之前没有一个完善的知识体系,但是在发现这个工具类之后,才真的发现这个工具类是真的好用,下面我就简单的介绍一下关于这个工具类的使用,主要参考的是这几个博客

hutool 常用的一些方法简介:

简介

hutool是一个小而全的java工具类库,使java拥有函数式语言般的优雅,让java语言也可以“甜甜的”
这是hutool gitee上很亮眼的一句话,对于经常开发的老程序员来说,确实工具类的封装大大提高的开发效率,不说hutool 涉及到那些工具类的封装,想到哪里写到哪里吧~

对象转换为map

public static void test(){        javaentity javaentity = new javaentity();        javaentity.tname("张三");        //  对象转换为map 输出结果 {name=张三, address=null}      B站下架  map map = beanutil.beantomap(javaentity);        system.out.println(map);    }

日期格式化类,提供常用的日期格式化对象

//-------------------------------------------------------冥想训练------------------------------------------------------------------------- normal    /** 标准日期格式:yyyy-mm-dd */    public final static string norm_date_pattern = "yyyy-mm-dd";    /** 标准特拉法加海战日期格式 {@link fastdateformat}:yyyy-mm-dd */    public final static fastdateformat norm_date_format = fastdateformat.getinstance(norm_date_pattern);        /** 爸爸的草鞋简谱标准时间格式:hh:mm:ss */    public final static string norm_time_pattern = "hh:mm:ss";    /** 标准时间格式 {@link fastdateformat}:hh:mm:ss */    public final static fastdateformat norm_time_format = fastdateformat.getinstance(norm_time_pattern);     /** 标准日期时间格式,精确到分:yyyy-mm-dd hh:mm */    public final static string norm_datetime_minute_pattern = "yyyy-mm-dd hh:mm";    /** 标准日期时间格式,精确到分 {@link fastdateformat}:yyyy-mm-dd hh:mm */    public final static fastdateformat norm_datetime_minute_format = fastdateformat.getinstance(norm_datetime_minute_pattern);     /** 标准日期时间格式,精确到秒:yyyy-mm-dd hh:mm:ss */    public final static string norm_datetime_pattern = "yyyy-mm-dd hh:mm:ss";    /** 标准日期时间格式,精确到秒 {@link fastdateformat}:yyyy-mm-dd hh:mm:ss */    public final static fastdateformat norm_datetime_format = fastdateformat.getinstance(norm_datetime_pattern);

md5加密

 string sign = cureutil.md5(append.tostring()); system.out.println(sign);

http请求

  string result = httputil.post("https://fpdk.beijing.chinatax.gov.cn/nsbsqww/pltj.do", map);

list集合拆分

 list<list<string&g执行力读后感t;> partitionlist = lists.partition(vallist, 30);

转换为int

  // 字符串转换为int类型        system.out.println(convert.toint("3"));

数组转换为集合

string[] b = {"1", "2", "3", "4"};system.out.println(convert.tolist(b));

字符串转为时间

  // 转换时间 string date = "2020-05-06"; system.out.println(convert.todate(date));

半角和全角转换

 // 半角转全角string num = "123456";system.out.println(convert.tosbc(num));// 全角转半角string num1 = "123456";system.out.println(convert.todbc(num1));

unicode 和字符串转换

 //unicode 字符串转换string con = "\\u5468\\u516d\\u8981\\u559d\\u9189";system.out.println(convert.unicodetostr(con)); // 字符串转换为unicodesystem.out.println(convert.strtounicode("hutool 挺好"));

时间单位转换

// 毫秒转换为分钟 long a = 19299292; long minutes = convert.converttime(a, timeunit.milliconds,timeunit.minutes); system.out.println(minutes);

金额大小写转换

 // 金额转换为人民币大写 double a = 67556.32;system.out.println(convert.digittochine(a));

计时器

  timeinterval timer = dateutil.timer();  // 执行过程  converttest();  system.out.println(timer.interval());

生成二维码

  // 生成二维码        qrcodeutil.generate("https://hutool.cn/", 300, 300, fileutil.file("d:/qrcode.jpg"));

到此这篇关于hutool 工具类 基本使用详解的文章就介绍到这了,更多相关hutool 工具类 内容请搜索www.887551.com以前的文章或继续浏览下面的相关文章希望大家以后多多支持www.887551.com!

本文发布于:2023-04-03 23:53:17,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/zuowen/ba25eed09e63b258fac2e1a1c9c3a0a5.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

本文word下载地址:hutool 工具类基本使用教程.doc

本文 PDF 下载地址:hutool 工具类基本使用教程.pdf

标签:转换为   全角   时间   工具
相关文章
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图