This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getServerDate() { | |
let date = null; | |
try { | |
let xhr = new XMLHttpRequest(); | |
if (!xhr) { | |
xhr = new ActiveXObject('Microsoft.XMLHTTP'); | |
} | |
xhr.open('HEAD', '/', false); | |
xhr.send(null); | |
const nowDate = xhr.getResponseHeader('Date'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//去重 | |
List<OnlineFactor> finalList = factorList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(x -> x.getName() + x.getCode()))), ArrayList::new)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//数组去重 | |
const uniqueArr = (arr) => [...new Set(arr)]; | |
console.log(uniqueArr(["前端","js","html","js","css","html"])); | |
//两日期之间相差的天数 | |
const dayDiff = (date1, date2) => Math.ceil(Math.abs(date1.getTime() - date2.getTime()) / 86400000); | |
dayDiff(new Date("2021-10-21"), new Date("2022-02-12")) | |
//判断数组是否为空 | |
const isNotEmpty = arr => Array.isArray(arr) && arr.length > 0; |