Java高级开发技巧记录

//对象拷贝
BeanUtils.copyProperties(object, object)

//集合工具
CollectionUtils.isEmpty(list)
List<Long> ids = items.stream().map(p -> p.getId()).collect(Collectors.toList());
list.stream()
    .filter(p -> TradeStatus.ONLINE.name().equalsIgnoreCase(p.getTradeStatus()))
    .forEach(p -> {

    });

//字符串工具
Strings.nullToEmpty(string)

//A|B|C|D|E
List<String> head = Arrays.asList("A", "B", "C", "D", "E");
String rowStr = String.join(separator, head);

//对象工具
Objects.equals(object, object)
Objects.isNull(object)
Objects.nonNull(object)

//日期工具
Date now = DateUtils.truncate(dateTimeHelper.selectDateTime(), Calendar.DAY_OF_MONTH);
String begin = DateFormatUtils.format(DateUtils.addDays(now, -req.getLatestDays()), "yyyyMMdd");
String end = DateFormatUtils.format(DateUtils.addDays(now, -1), "yyyyMMdd");

Date date = "20200101";
DateFormatUtils.format(DateUtils.addDays(date, -1), "yyyyMMdd");

//BigDecimal运算
new BigDecimal(100).divide(new BigDecimal(10000))

//大写
WordUtils.capitalize(profile)

//map遍历
map.entrySet().forEach(entry -> {

});

//线程安全
List<T> list = Collections.synchronizedList(new LinkedList<>());

//AtomicInteger
AtomicInteger count = new AtomicInteger(0);
count.incrementAndGet()
count.intValue()
count.addAndGet(5)
上一篇 Java判断IP地址是否在CIDR范围内
下一篇 基于JWT的token身份认证方案
目录
文章列表
1 CURL使用SSL证书访问HTTPS
CURL使用SSL证书访问HTTPS
2
Android引用Library的若干问题
Android引用Library的若干问题
3
H5唤起App技术DeepLink方案总结
H5唤起App技术DeepLink方案总结
4
Vue常用的ES6语法之数据集合map
Vue常用的ES6语法之数据集合map
5
Spring Security OAuth2 JWT 认证服务器配置
Spring Security OAuth2 JWT 认证服务器配置
最新评论
一位WordPress评论者
一位WordPress评论者
2月12日
您好,这是一条评论。若需要审核、编辑或删除评论,请访问仪表盘的评论界面。评论者头像来自 Gravatar。