| Modifier and Type | Method and Description |
|---|---|
static <T extends Throwable> |
ExceptionUtil.clearStackTrace(T throwable)
清除StackTrace.
|
static <T extends Throwable> |
ExceptionUtil.findCause(Throwable throwable,
Class<T> cause)
获取某种类型的cause,如果没有则返回空
copy from Jodd ExceptionUtil
|
static Throwable |
ExceptionUtil.getRootCause(Throwable t)
获取异常的Root Cause.
|
static <T extends Throwable> |
ExceptionUtil.setStackTrace(T throwable,
Class<?> throwClass,
String throwClazz)
copy from Netty, 为静态异常设置StackTrace.
|
static String |
ExceptionUtil.stackTraceText(Throwable t)
将StackTrace[]转换为String, 供Logger或e.printStackTrace()外的其他地方使用.
|
| Modifier and Type | Method and Description |
|---|---|
static <K,V> V |
MapUtil.createIfAbsentReturnLast(ConcurrentMap<K,V> map,
K key,
MapUtil.ValueCreator<? extends V> creator)
如果Key不存在则创建,返回最后存储在Map中的Value.
|
static <K,V> V |
MapUtil.createIfAbsentReturnLast(ConcurrentMap<K,V> map,
K key,
MapUtil.ValueCreator<? extends V> creator)
如果Key不存在则创建,返回最后存储在Map中的Value.
|
static <K extends Enum<K>,V> |
MapUtil.newEnumMap(Class<K> type)
相比HashMap,当key是枚举类时, 性能与空间占用俱佳.
|
static <K,V> HashMap<K,V> |
MapUtil.newHashMap(K[] keys,
V[] values)
根据等号左边的类型, 构造类型正确的HashMap.
|
static <K,V> HashMap<K,V> |
MapUtil.newHashMap(K[] keys,
V[] values)
根据等号左边的类型, 构造类型正确的HashMap.
|
static <K,V> HashMap<K,V> |
MapUtil.newHashMap(List<K> keys,
List<V> values)
根据等号左边的类型, 构造类型正确的HashMap.
|
static <K,V> HashMap<K,V> |
MapUtil.newHashMap(List<K> keys,
List<V> values)
根据等号左边的类型, 构造类型正确的HashMap.
|
static <K,V> V |
MapUtil.putIfAbsentReturnLast(ConcurrentMap<K,V> map,
K key,
V value)
ConcurrentMap的putIfAbsent()返回之前的Value,此函数封装返回最终存储在Map中的Value
|
| Modifier and Type | Method and Description |
|---|---|
static ThreadFactory |
ThreadPoolUtil.buildThreadFactory(String threadNamePrefix)
创建ThreadFactory,使得创建的线程有自己的名字而不是默认的"pool-x-thread-y"
使用了Guava的工具类
|
static ThreadFactory |
ThreadPoolUtil.buildThreadFactory(String threadNamePrefix,
boolean daemon)
可设定是否daemon, daemon线程在主线程已执行完毕时, 不会阻塞应用不退出, 而非daemon线程则会阻塞.
|
static ThreadFactory |
ThreadPoolUtil.buildThreadFactory(String threadNamePrefix,
boolean daemon)
可设定是否daemon, daemon线程在主线程已执行完毕时, 不会阻塞应用不退出, 而非daemon线程则会阻塞.
|
static Runnable |
ThreadPoolUtil.safeRunnable(Runnable runnable)
防止用户没有捕捉异常导致中断了线程池中的线程, 使得SchedulerService无法继续执行.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
FileUtil.copy(File from,
File to)
复制文件或目录, not following links.
|
static void |
FileUtil.copy(File from,
File to)
复制文件或目录, not following links.
|
static void |
FileUtil.copy(Path from,
Path to)
复制文件或目录, not following links.
|
static void |
FileUtil.copy(Path from,
Path to)
复制文件或目录, not following links.
|
static void |
FileUtil.copyDir(File from,
File to)
复制目录
|
static void |
FileUtil.copyDir(File from,
File to)
复制目录
|
static void |
FileUtil.copyDir(Path from,
Path to)
复制目录
|
static void |
FileUtil.copyDir(Path from,
Path to)
复制目录
|
static void |
FileUtil.copyFile(File from,
File to)
文件复制.
|
static void |
FileUtil.copyFile(File from,
File to)
文件复制.
|
static void |
FileUtil.copyFile(Path from,
Path to)
文件复制.
|
static void |
FileUtil.copyFile(Path from,
Path to)
文件复制.
|
static String |
FileUtil.getFileName(String fullName)
获取文件名(不包含路径)
|
static void |
FileUtil.moveDir(File from,
File to)
目录移动/重命名
|
static void |
FileUtil.moveDir(File from,
File to)
目录移动/重命名
|
static void |
FileUtil.moveFile(File from,
File to)
文件移动/重命名.
|
static void |
FileUtil.moveFile(File from,
File to)
文件移动/重命名.
|
static void |
FileUtil.moveFile(Path from,
Path to)
文件移动/重命名.
|
static void |
FileUtil.moveFile(Path from,
Path to)
文件移动/重命名.
|
| Modifier and Type | Method and Description |
|---|---|
static Integer |
NumberUtil.hexToIntObject(String str)
将16进制的String转化为Integer.
|
static Long |
NumberUtil.hexToLongObject(String str)
将16进制的String转化为Long
当str为空或非数字字符串时抛NumberFormatException
|
static double |
NumberUtil.toDouble(String str)
将10进制的String安全的转化为double.
|
static Double |
NumberUtil.toDoubleObject(String str)
将10进制的String安全的转化为Double.
|
static int |
NumberUtil.toInt(String str)
将10进制的String转化为int.
|
static Integer |
NumberUtil.toIntObject(String str)
将10进制的String安全的转化为Integer.
|
static long |
NumberUtil.toLong(String str)
将10进制的String安全的转化为long.
|
static Long |
NumberUtil.toLongObject(String str)
将10进制的String安全的转化为Long.
|
static String |
NumberUtil.toString(Double d) |
static String |
NumberUtil.toString(Integer i) |
static String |
NumberUtil.toString(Long l) |
| Modifier and Type | Method and Description |
|---|---|
static int |
HashUtil.crc32AsInt(byte[] input)
对输入字符串进行crc32散列返回int, 返回值有可能是负数.
|
static int |
HashUtil.crc32AsInt(String input)
对输入字符串进行crc32散列返回int, 返回值有可能是负数.
|
static long |
HashUtil.crc32AsLong(byte[] input)
对输入字符串进行crc32散列,与php兼容,在64bit系统下返回永远是正数的long
Guava也有crc32实现, 但返回值无法返回long,所以统一使用JDK默认实现
|
static long |
HashUtil.crc32AsLong(String input)
对输入字符串进行crc32散列,与php兼容,在64bit系统下返回永远是正数的long
Guava也有crc32实现, 但返回值无法返回long,所以统一使用JDK默认实现
|
static long |
HashUtil.murmur128AsLong(byte[] input)
对输入字符串进行murmur128散列, 返回值可能是负数
|
static long |
HashUtil.murmur128AsLong(String input)
对输入字符串进行murmur128散列, 返回值可能是负数
|
static int |
HashUtil.murmur32AsInt(byte[] input)
对输入字符串进行murmur32散列, 返回值可能是负数
|
static int |
HashUtil.murmur32AsInt(String input)
对输入字符串进行murmur32散列, 返回值可能是负数
|
static byte[] |
HashUtil.sha1(byte[] input)
对输入字符串进行sha1散列.
|
static byte[] |
HashUtil.sha1(byte[] input,
byte[] salt)
对输入字符串进行sha1散列,带salt达到更高的安全性.
|
static byte[] |
HashUtil.sha1(byte[] input,
byte[] salt,
int iterations)
对输入字符串进行sha1散列,带salt而且迭代达到更高更高的安全性.
|
static byte[] |
HashUtil.sha1(String input)
对输入字符串进行sha1散列, 编码默认为UTF8.
|
static byte[] |
HashUtil.sha1(String input,
byte[] salt)
对输入字符串进行sha1散列,带salt达到更高的安全性.
|
static byte[] |
HashUtil.sha1(String input,
byte[] salt,
int iterations)
对输入字符串进行sha1散列,带salt而且迭代达到更高更高的安全性.
|
| Modifier and Type | Method and Description |
|---|---|
static Date |
DateUtil.addDays(Date date,
int amount)
加一天
|
static Date |
DateUtil.addHours(Date date,
int amount)
加一小时
|
static Date |
DateUtil.addMinutes(Date date,
int amount)
加一分钟
|
static Date |
DateUtil.addMonths(Date date,
int amount)
加一月
|
static Date |
DateUtil.addSeconds(Date date,
int amount)
终于到了,续一秒.
|
static Date |
DateUtil.addWeeks(Date date,
int amount)
加一周
|
static Date |
DateUtil.beginOfDate(Date date)
2016-11-10 07:33:23, 则返回2016-11-10 00:00:00
|
static Date |
DateUtil.beginOfHour(Date date)
2016-12-10 07:33:23, 则返回2016-12-10 07:00:00
|
static Date |
DateUtil.beginOfMinute(Date date)
2016-12-10 07:33:23, 则返回2016-12-10 07:33:00
|
static Date |
DateUtil.beginOfMonth(Date date)
2016-11-10 07:33:23, 则返回2016-11-1 00:00:00
|
static Date |
DateUtil.beginOfWeek(Date date)
2017-1-20 07:33:23, 则返回2017-1-16 00:00:00
|
static Date |
DateUtil.beginOfYear(Date date)
2016-11-10 07:33:23, 则返回2016-1-1 00:00:00
|
static Date |
DateUtil.endOfDate(Date date)
2017-1-23 07:33:23, 则返回2017-1-23 23:59:59.999
|
static Date |
DateUtil.endOfHour(Date date)
2017-1-23 07:33:23, 则返回2017-1-23 07:59:59.999
|
static Date |
DateUtil.endOfMinute(Date date)
2017-1-23 07:33:23, 则返回2017-1-23 07:33:59.999
|
static Date |
DateUtil.endOfMonth(Date date)
2016-11-10 07:33:23, 则返回2016-11-30 23:59:59.999
|
static Date |
DateUtil.endOfWeek(Date date)
2017-1-20 07:33:23, 则返回2017-1-22 23:59:59.999
|
static Date |
DateUtil.endOfYear(Date date)
2016-11-10 07:33:23, 则返回2016-12-31 23:59:59.999
|
static String |
DateFormatUtil.formatDate(String pattern,
Date date)
格式化日期, 仅用于pattern不固定的情况.
|
static String |
DateFormatUtil.formatDate(String pattern,
Date date)
格式化日期, 仅用于pattern不固定的情况.
|
static String |
DateFormatUtil.formatDate(String pattern,
long date)
格式化日期, 仅用于不固定pattern不固定的情况.
|
static String |
DateFormatUtil.formatDuration(Date startDate,
Date endDate)
按HH:mm:ss.SSS格式,格式化时间间隔.
|
static String |
DateFormatUtil.formatDuration(Date startDate,
Date endDate)
按HH:mm:ss.SSS格式,格式化时间间隔.
|
static String |
DateFormatUtil.formatDurationOnSecond(Date startDate,
Date endDate)
按HH:mm:ss格式,格式化时间间隔
endDate必须大于startDate,间隔可大于1天
|
static String |
DateFormatUtil.formatDurationOnSecond(Date startDate,
Date endDate)
按HH:mm:ss格式,格式化时间间隔
endDate必须大于startDate,间隔可大于1天
|
static String |
DateFormatUtil.formatFriendlyTimeSpanByNow(Date date)
打印用户友好的,与当前时间相比的时间差,如刚刚,5分钟前,今天XXX,昨天XXX
copy from AndroidUtilCode
|
static int |
DateUtil.getDayOfWeek(Date date)
获得日期是一周的第几天.
|
static int |
DateUtil.getDayOfYear(Date date)
获得日期是一年的第几天,返回值从1开始
|
static int |
DateUtil.getMonthLength(Date date)
获取某个月有多少天, 考虑闰年等因数, 移植Jodd Core的TimeUtil
|
static int |
DateUtil.getWeekOfMonth(Date date)
获得日期是一月的第几周,返回值从1开始.
|
static int |
DateUtil.getWeekOfYear(Date date)
获得日期是一年的第几周,返回值从1开始.
|
static boolean |
DateUtil.isBetween(Date date,
Date start,
Date end)
判断日期是否在范围内,包含相等的日期
|
static boolean |
DateUtil.isBetween(Date date,
Date start,
Date end)
判断日期是否在范围内,包含相等的日期
|
static boolean |
DateUtil.isBetween(Date date,
Date start,
Date end)
判断日期是否在范围内,包含相等的日期
|
static boolean |
DateUtil.isLeapYear(Date date)
是否闰年.
|
static boolean |
DateUtil.isSameDay(Date date1,
Date date2)
是否同一天.
|
static boolean |
DateUtil.isSameDay(Date date1,
Date date2)
是否同一天.
|
static boolean |
DateUtil.isSameTime(Date date1,
Date date2)
是否同一时刻.
|
static boolean |
DateUtil.isSameTime(Date date1,
Date date2)
是否同一时刻.
|
static Date |
DateUtil.nextDate(Date date)
2016-11-10 07:33:23, 则返回2016-11-11 00:00:00
|
static Date |
DateUtil.nextHour(Date date)
2016-12-10 07:33:23, 则返回2016-12-10 08:00:00
|
static Date |
DateUtil.nextMinute(Date date)
2016-12-10 07:33:23, 则返回2016-12-10 07:34:00
|
static Date |
DateUtil.nextMonth(Date date)
2016-11-10 07:33:23, 则返回2016-12-1 00:00:00
|
static Date |
DateUtil.nextWeek(Date date)
2017-1-23 07:33:23, 则返回2017-1-22 00:00:00
|
static Date |
DateUtil.nextYear(Date date)
2016-11-10 07:33:23, 则返回2017-1-1 00:00:00
|
static Date |
DateFormatUtil.parseDate(String pattern,
String dateString)
分析日期字符串, 仅用于pattern不固定的情况.
|
static Date |
DateFormatUtil.parseDate(String pattern,
String dateString)
分析日期字符串, 仅用于pattern不固定的情况.
|
static Date |
DateUtil.setDays(Date date,
int amount)
设置日期, 1-31.
|
static Date |
DateUtil.setHours(Date date,
int amount)
设置小时, 0-23.
|
static Date |
DateUtil.setMilliseconds(Date date,
int amount)
设置毫秒.
|
static Date |
DateUtil.setMinutes(Date date,
int amount)
设置分钟, 0-59.
|
static Date |
DateUtil.setMonths(Date date,
int amount)
设置月份, 1-12.
|
static Date |
DateUtil.setSeconds(Date date,
int amount)
设置秒, 0-59.
|
static Date |
DateUtil.setYears(Date date,
int amount)
设置年份, 公元纪年.
|
static Date |
DateUtil.subDays(Date date,
int amount)
减一天
|
static Date |
DateUtil.subHours(Date date,
int amount)
减一小时
|
static Date |
DateUtil.subMinutes(Date date,
int amount)
减一分钟
|
static Date |
DateUtil.subMonths(Date date,
int amount)
减一月
|
static Date |
DateUtil.subSeconds(Date date,
int amount)
减一秒.
|
static Date |
DateUtil.subWeeks(Date date,
int amount)
减一周
|
Copyright © 2018. All rights reserved.