随笔分类 - 工具类
TimeUnit
摘要:TimeUnit是java.util.concurrent包下面的一个类,表示给定单元粒度的时间段。 常用来做时间颗粒度转换。 常用的颗粒度 TimeUnit.DAYS //天 TimeUnit.HOURS //小时 TimeUnit.MINUTES //分钟 TimeUnit.SECONDS //
阅读全文
NumberUtils
摘要:org.apache.commons.lang3.math.NumberUtils 将字符串转换成 int 类型,如果转换失败则返回0或指定的默认值 public static int toInt(final String str) public static int toInt(final Str
阅读全文
ObjectUtils 和 Objects
摘要:ObjectUtils org.apache.commons.lang3.ObjectUtils 如果传递的对象是 null,则返回defaultValue public static <T> T defaultIfNull(final T object, final T defaultValue)
阅读全文
DateUtils 和 DateFormatUtils
摘要:DateUtils org.apache.commons.lang3.time.DateUtils 判断两个日期是否是同一天 public static boolean isSameDay(final Date date1, final Date date2) 判断两个日期是否在时间上表示同一时刻(
阅读全文
IOUtils
摘要:org.apache.commons.io.IOUtils 将字节流转换成缓冲字节流 public static InputStream toBufferedInputStream(InputStream input) 将输入流写入字节数组 public static byte[] toByteAr
阅读全文
FilenameUtils
摘要:import org.apache.commons.io.FilenameUtils; 测试数据 String fileDirectory = "/D:/aa/bb/cc"; String fileName ="file.txt"; String fileFullName = fileDirecto
阅读全文
FileUtils
摘要:org.apache.commons.io.FileUtils 创建输入流 public static FileInputStream openInputStream(File file) 说明:openInputStream(file) 与 new FileInputStream(file) 作用
阅读全文
ArrayUtils
摘要:org.apache.commons.lang3.ArrayUtils 向数组末尾添加元素 ArrayUtils.add(strs, "str3"); 向数组指定位置添加元素 ArrayUtils.add(strs, 1, "str3"); 向数组中添加所有元素 ArrayUtils.addAll(
阅读全文
CollectionUtils
摘要:org.apache.commons.collections.CollectionUtils; 判断集合非空 / 为空 CollectionUtils.isNotEmpty(list); 不会排除null和""。 CollectionUtils.isEmpty(list); 并交差集 List<In
阅读全文
StringUtils
摘要:org.apache.commons.lang3.StringUtils lang3是Apache Commons 团队发布的工具包,要求jdk版本在1.5以上,相对于 org.apache.commons.lang.StringUtils 来说完全支持java5的特性,废除了一些旧的API。该版本
阅读全文
浙公网安备 33010602011771号