时间函数
获取当前时间: DateUtil.today()
String today=DateUtil.today()
String today = “2024-02-01”;
时间偏移
往前30天
DateTime parseDateUtil.offsetDay(DateUtil.parse(DateUtil.today()), -30)
String today =DateUtil.formatDate(DateUtil.offsetDay(DateUtil.parse(DateUtil.today()), -45));
字符换时间格式化
DateTime parse = DateUtil.parse(DateUtil.today());
String today =DateUtil.formatDate(parse)
map.computeIfAbsent添加list
postIdMap.computeIfAbsent(dingDaykey.getPostId(), k -> new LinkedList<>()).add(dingDaykey);
优化前
DayEntity dayEntity = lkeyMap.get(line);
if (dayEntity == null) {
dayEntity = new DayEntity();
}
dayEntity.setName(line);
优化后
DayEntity dayEntity = lkeyMap.computeIfAbsent(line, DayEntity::new);
优化前
List<DataListMxfEntity> data = dayEntity.getData();
if (data == null) {
data = new ArrayList<>();
}
优化后
List<DataListMxfEntity> data = Optional.ofNullable(dayEntity.getData()).orElseGet(ArrayList::new);
优化前文章来源:https://www.toymoban.com/news/detail-836916.html
List<AgvSg03PsPlcItemHistoryDO> agvSg03PsPlcItemHistoryDOS1 = batteryIdMapList.get(batteryId);
if (agvSg03PsPlcItemHistoryDOS1 == null) {
agvSg03PsPlcItemHistoryDOS1 = new ArrayList<>();
}
优化后文章来源地址https://www.toymoban.com/news/detail-836916.html
List<AgvSg03PsPlcItemHistoryDO> agvSg03PsPlcItemHistoryDOS1 = Optional.ofNullable(batteryIdMapList.get(batteryId))
.orElseGet(ArrayList::new);
到了这里,关于java----js常用的api的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!