Commit f689c85c by 高晓磊

时间工具类增加 根据date类型获取年初年末

parent be3163e1
...@@ -215,6 +215,30 @@ public class DateTimeUtils { ...@@ -215,6 +215,30 @@ public class DateTimeUtils {
/** /**
* 获取某年第一天第一秒日期 eg 2021-01-01 00:00:00
*
* @param date 时间
* @return Date
*/
public static Date getYearStart(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
return getYearStart(calendar.get(Calendar.YEAR));
}
/**
* 获取某年最后一天最后一秒日期 eg 2021-12-31 23:59:59
*
* @param date 年份
* @return Date
*/
public static Date getYearEnd(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
return getYearEnd(calendar.get(Calendar.YEAR));
}
/**
* 获取月初第一秒 eg 2021-04-01 00:00:00 * 获取月初第一秒 eg 2021-04-01 00:00:00
* *
* @param date * @param date
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment