一、集合类
boolean b = list1.addAll(list2)
boolean notEmpty = CollectionUtils.isNotEmpty(list);
boolean empty = CollectionUtils.isEmpty(list);
isBlank空字符串也算空,而isEmpty不算空
boolean notEmpty = StringUtils.isNotEmpty(str);
boolean empty = StringUtils.isEmpty(str);
boolean notBlank = StringUtils.isNotBlank(str);
boolean blank = StringUtils.isBlank(str);
String str = "str";
String str1 = null;
boolean b = Objects.nonNull(str);
boolean b1 = Objects.nonNull(str1);
boolean aNull = Objects.isNull(str);
boolean aNull1 = Objects.isNull(str1);
String 要求不为空 = Objects.requireNonNull(str, "要求不为null");
BigDecimal add = bigDecimal.add(bigDecimal1);
BigDecimal subtract = bigDecimal.subtract(bigDecimal1);
BigDecimal abs = bigDecimal2.abs();
BigDecimal bigDecimal3 = bigDecimal1.setScale(2, BigDecimal.ROUND_HALF_UP);
BigDecimal bigDecimal4 = bigDecimal1.setScale(1, BigDecimal.ROUND_HALF_DOWN);
BigDecimal reduce = list.stream().reduce(BigDecimal.ZERO, BigDecimal::add); // 从零开始累加
long start = System.currentTimeMillis(); //毫秒
try {
Thread.sleep(1000);
} catch (Exception e) {
e.printStackTrace();
}
long end = System.currentTimeMillis();
long l = end - start; //毫秒
long l1 = l / 1000; //秒
Date start = new Date();
try {
Thread.sleep(10000);
} catch (Exception e) {
e.printStackTrace();
}
Date end = new Date();
long second = (end.getTime() - start.getTime()) / 1000;