自定义工具类,获取当前时间到第二天的零点、下个月1号零点的时间差(s):
cacheManager.set(monthKey, totalMonCount.toString(), DateUtil.getSecsToEndOfCurrentDay());public class DateUtil {
/**
*获取每月最后一天时间
* @param sDate1
* @return
*/
public static Date getLastDayOfMonth(Date sDate1) {
Calendar cDay1 = Calendar.getInstance();
cDay1.setTime(sDate1); final int lastDay = cDay1.getActualMaximum(Calendar.DAY_OF_MONTH);
Date lastDate = cDay1.getTime();
lastDate.setDate(lastDay); return lastDate;
} /*
获取下一个月第一天凌晨1点
*/
public static Date nextMonthFirstDate() {
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, 1); //设置为每月凌晨1点
calendar.set(Calendar.DAY_OF_MONTH, 1); //设置为每月1号
calendar.add(Calendar.MONTH, 1); // 月份加一,得到下个月的一号// calendar.add(Calendar.DATE, -1); 下一个月减一为本月最后一天
return calendar.getTime();
} /**
* 获取第二天凌晨0点毫秒数
* @return
*/
public static Date nextDayFirstDate() throws ParseException {
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.add(Calendar.DAY_OF_YEAR, 1);
cal.set(Calendar.HOUR_OF_DAY, 00);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0); return cal.getTime();
} //*********
/**
* 获取当前时间到下个月凌晨1点相差秒数
* @return
*/
public static Long getSecsToEndOfCurrentMonth(){
Long secsOfNextMonth = nextMonthFirstDate().getTime(); //将当前时间转为毫秒数
Long secsOfCurrentTime = new Date().getTime(); //将时间转为秒数
Long distance = (secsOfNextMonth - secsOfCurrentTime)/1000; if (distance > 0 && distance != null){ return distance;
} return new Long(0);
} /**
* 获取当前时间到明天凌晨0点相差秒数
* @return
*/
public static Long getSecsToEndOfCurrentDay() throws ParseException {
Long secsOfNextDay = nextDayFirstDate().getTime(); //将当前时间转为毫秒数
Long secsOfCurrentTime = new Date().getTime(); //将时间转为秒数
Long distance = (secsOfNextDay - secsOfCurrentTime)/1000; if (distance > 0 && distance != null){ return distance;
} return new Long(0);
}
}
-
vue-echarts 'createElement()` has been called outside of render function.
添加VueCompositionAPI解决
-
ReferenceError: regeneratorRuntime is not defined
原因是不能解析async … await 等高级语法
-
用 vuetify-loader 提升 Vue 开发体验
不用 Vuetify 也可以用 vuetify-loader 哦
-
android toolbar setTitle 出现省略号
怎么配置都不行,后来我用了异步设置 ,在线程中设置title,完美解决了。
-
windows下安装emscripten
windows下安装emscripten需要python、git环境
-
blocked by cors policy about CORS-RFC1918,或者local
这个错误事chrome浏览器升级到94版本后出现的
-
chrome.webRequest redirect 的另一种写法data-URLs
chrome.webRequest redirect data-URLs
-
Android 11 adb无线调试使用方法
Android 11无线调试不需要再像以前一样,先插上usb线,输入命令来启用无线调试,再进行无线连接了。Android 11系统设置开发者选项中自带了无线调试,今天亲自测试了
-
react native开发遇到的问题一
接下来讲一下啊继承react navigation遇到的问题
-
react native开发遇到的问题二
集成react-nativ-webview,出现这样的错误"RNCWebView" was not found in the UIManager