//时间戳转日期20220406
public static String parseDateToStr(Date time, String timeFormat) {
DateFormat dateFormat = new SimpleDateFormat(timeFormat);
return dateFormat.format(time);
}
//获取当天的开始时间
public static Long getNowDayStartTime(Date dateParam) {
String startTime = DateFormatUtils.format(dateParam, "yyyy-MM-dd 00:00:00");
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = null;
try {
date = simpleDateFormat.parse(startTime);
} catch (ParseException e) {
e.printStackTrace();
}
return date.getTime();
}
//获取当天的结束时间
public static Long getNowDayEndTime(Date dateParam) {
String endTime = DateFormatUtils.format(dateParam, "yyyy-MM-dd 23:59:59");
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = null;
try {
date = simpleDateFormat.parse(endTime);
} catch (ParseException e) {
e.printStackTrace();
}
return date.getTime();
}
public static Date getDayEnd() {
Calendar cal = Calendar.getInstance();
cal.set(11, 23);
cal.set(12, 59);
cal.set(13, 59);
return cal.getTime();
}
时间格式转换
最新推荐文章于 2024-08-24 22:01:16 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)