总结工作中的一些常用的方法希望大家一起完善,偶尔忘记了快速找到,【方便搬砖】
1.List to String
StringUtils.join(list, ",")
String.join(",", list)
2.String to List
Arrays.stream(entity.getMaterials().split(",")).map(material -> String.format(material.trim())).collect(Collectors.toList())
3.List 排序
vos.sort((x, y) -> y.getLastDate().compareTo(x.getLastDate()));
4.List to mapList
dtoList.stream().collect(Collectors.groupingBy(FindModularInfoDTO::getModularInfoType))
5.List to String[]
String[] string = set.toArray(new String[set.size()]);
6.Date to LocalDate
Date.from(LocalDate.now().atStartOfDay().atZone(ZoneId.systemDefault()).toInstant())
7.Localdate to Date
meetingBeforeDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime()
8.Maven
mvn
-Dskiptests = true 跳过测试
compile -X 输出详细的编译信息【报错是方便查看】
9.Java 重启项目
ps -ef | grep xxx | grep -v 'grep' | awk '{print $2}'| xargs kill -9
nohup java -jar xxx.jar --spring.profiles.active=xx >> xxx.log &