|
@@ -35,9 +35,7 @@ public class DateUtils extends PropertyEditorSupport {
|
|
public static Date getNowDate() throws ParseException {
|
|
public static Date getNowDate() throws ParseException {
|
|
SimpleDateFormat dsdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
SimpleDateFormat dsdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
String nowDate = getNowDate("yyyy-MM-dd");
|
|
String nowDate = getNowDate("yyyy-MM-dd");
|
|
- Date parse = dsdf.parse(nowDate);
|
|
|
|
- return parse;
|
|
|
|
-
|
|
|
|
|
|
+ return dsdf.parse(nowDate);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -47,28 +45,14 @@ public class DateUtils extends PropertyEditorSupport {
|
|
//将字符串形式的时间转化为Date类型的时间
|
|
//将字符串形式的时间转化为Date类型的时间
|
|
Date a = sdf.parse(beginDate);
|
|
Date a = sdf.parse(beginDate);
|
|
Date b = sdf.parse(nowDate);
|
|
Date b = sdf.parse(nowDate);
|
|
- //Date类的一个方法,如果a早于b返回true,否则返回false
|
|
|
|
- if (a.before(b)) {
|
|
|
|
- return true;
|
|
|
|
- } else {
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /*
|
|
|
|
- * 如果你不喜欢用上面这个太流氓的方法,也可以根据将Date转换成毫秒
|
|
|
|
- if(a.getTime()-b.getTime()<0)
|
|
|
|
- return true;
|
|
|
|
- else
|
|
|
|
- return false;
|
|
|
|
- */
|
|
|
|
|
|
+ return a.before(b);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
public static String getDateByDateStr(String dateStr) throws ParseException {
|
|
public static String getDateByDateStr(String dateStr) throws ParseException {
|
|
SimpleDateFormat dsdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
SimpleDateFormat dsdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
Date parse = dsdf.parse(dateStr);
|
|
Date parse = dsdf.parse(dateStr);
|
|
- String day = dsdf.format(parse);
|
|
|
|
- return day;
|
|
|
|
|
|
+ return dsdf.format(parse);
|
|
}
|
|
}
|
|
|
|
|
|
public static Integer getHour(String dateStr) throws ParseException {
|
|
public static Integer getHour(String dateStr) throws ParseException {
|
|
@@ -76,10 +60,7 @@ public class DateUtils extends PropertyEditorSupport {
|
|
Calendar cal = Calendar.getInstance();
|
|
Calendar cal = Calendar.getInstance();
|
|
Date date = sdf.parse(dateStr);
|
|
Date date = sdf.parse(dateStr);
|
|
cal.setTime(date);
|
|
cal.setTime(date);
|
|
- Integer hour = cal.get(Calendar.HOUR_OF_DAY);
|
|
|
|
- return hour;
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+ return cal.get(Calendar.HOUR_OF_DAY);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -113,20 +94,6 @@ public class DateUtils extends PropertyEditorSupport {
|
|
return cal;
|
|
return cal;
|
|
}
|
|
}
|
|
|
|
|
|
- // ////////////////////////////////////////////////////////////////////////////
|
|
|
|
- // getDate
|
|
|
|
- // 各种方式获取的Date
|
|
|
|
- // ////////////////////////////////////////////////////////////////////////////
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 当前日期
|
|
|
|
- *
|
|
|
|
- * @return 系统当前时间
|
|
|
|
- */
|
|
|
|
- public static Date getDate() {
|
|
|
|
- return new Date();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 字符串转换成日期
|
|
* 字符串转换成日期
|
|
*
|
|
*
|
|
@@ -147,17 +114,6 @@ public class DateUtils extends PropertyEditorSupport {
|
|
}
|
|
}
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 日期转换为字符串
|
|
|
|
- *
|
|
|
|
- * @return 字符串
|
|
|
|
- */
|
|
|
|
- public static String date2Str() {
|
|
|
|
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
- return format.format(new Date());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 格式化时间
|
|
* 格式化时间
|
|
*
|
|
*
|
|
@@ -251,8 +207,7 @@ public class DateUtils extends PropertyEditorSupport {
|
|
Date dt = new Date();
|
|
Date dt = new Date();
|
|
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
String nowTime = df.format(dt);
|
|
String nowTime = df.format(dt);
|
|
- Timestamp buydate = Timestamp.valueOf(nowTime);
|
|
|
|
- return buydate;
|
|
|
|
|
|
+ return Timestamp.valueOf(nowTime);
|
|
}
|
|
}
|
|
|
|
|
|
// ////////////////////////////////////////////////////////////////////////////
|
|
// ////////////////////////////////////////////////////////////////////////////
|
|
@@ -516,10 +471,9 @@ public class DateUtils extends PropertyEditorSupport {
|
|
* @param src 将要转换的原始字符窜
|
|
* @param src 将要转换的原始字符窜
|
|
* @param pattern 转换的匹配格式
|
|
* @param pattern 转换的匹配格式
|
|
* @return 如果转换成功则返回转换后的日期
|
|
* @return 如果转换成功则返回转换后的日期
|
|
- * @throws ParseException
|
|
|
|
* @throws
|
|
* @throws
|
|
*/
|
|
*/
|
|
- public static Calendar parseCalendar(String src, String pattern) throws ParseException {
|
|
|
|
|
|
+ public static Calendar parseCalendar(String src, String pattern){
|
|
|
|
|
|
Date date = parseDate(src, pattern);
|
|
Date date = parseDate(src, pattern);
|
|
Calendar cal = Calendar.getInstance();
|
|
Calendar cal = Calendar.getInstance();
|
|
@@ -527,7 +481,7 @@ public class DateUtils extends PropertyEditorSupport {
|
|
return cal;
|
|
return cal;
|
|
}
|
|
}
|
|
|
|
|
|
- public static String formatAddDate(String src, String pattern, int amount) throws ParseException {
|
|
|
|
|
|
+ public static String formatAddDate(String src, String pattern, int amount) {
|
|
Calendar cal;
|
|
Calendar cal;
|
|
cal = parseCalendar(src, pattern);
|
|
cal = parseCalendar(src, pattern);
|
|
cal.add(Calendar.DATE, amount);
|
|
cal.add(Calendar.DATE, amount);
|
|
@@ -543,7 +497,7 @@ public class DateUtils extends PropertyEditorSupport {
|
|
* @throws ParseException
|
|
* @throws ParseException
|
|
* @throws
|
|
* @throws
|
|
*/
|
|
*/
|
|
- public static Timestamp parseTimestamp(String src, String pattern) throws ParseException {
|
|
|
|
|
|
+ public static Timestamp parseTimestamp(String src, String pattern) {
|
|
Date date = parseDate(src, pattern);
|
|
Date date = parseDate(src, pattern);
|
|
return new Timestamp(date.getTime());
|
|
return new Timestamp(date.getTime());
|
|
}
|
|
}
|
|
@@ -593,13 +547,10 @@ public class DateUtils extends PropertyEditorSupport {
|
|
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
|
|
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
|
|
Date date = sdf1.parse(createTime);
|
|
Date date = sdf1.parse(createTime);
|
|
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
- String str = sdf2.format(date);
|
|
|
|
-
|
|
|
|
- return str;
|
|
|
|
|
|
+ return sdf2.format(date);
|
|
}
|
|
}
|
|
|
|
|
|
public static Map<String, Object> getStartEndTime(String createTime) throws ParseException {
|
|
public static Map<String, Object> getStartEndTime(String createTime) throws ParseException {
|
|
-
|
|
|
|
SimpleDateFormat smf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
SimpleDateFormat smf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
Date parse = smf.parse(createTime);
|
|
Date parse = smf.parse(createTime);
|
|
Calendar calendar = Calendar.getInstance();
|
|
Calendar calendar = Calendar.getInstance();
|
|
@@ -646,7 +597,7 @@ public class DateUtils extends PropertyEditorSupport {
|
|
* HH:mm:ss“ * @param text String类型的时间值
|
|
* HH:mm:ss“ * @param text String类型的时间值
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public void setAsText(String text) throws IllegalArgumentException {
|
|
|
|
|
|
+ public void setAsText(String text) {
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
|
SimpleDateFormat datetimeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
SimpleDateFormat datetimeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
if (StringUtils.hasText(text)) {
|
|
if (StringUtils.hasText(text)) {
|
|
@@ -692,13 +643,13 @@ public class DateUtils extends PropertyEditorSupport {
|
|
String splitDate = DateUtils.addDay(endDate, -1);
|
|
String splitDate = DateUtils.addDay(endDate, -1);
|
|
splitDate = DateUtils.addDay(splitDate, 1);
|
|
splitDate = DateUtils.addDay(splitDate, 1);
|
|
if (DateUtils.compareDate(startDate, splitDate) >= 0) {
|
|
if (DateUtils.compareDate(startDate, splitDate) >= 0) {
|
|
- Map<String, String> map = new HashMap<String, String>();
|
|
|
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
map.put("startDate", startDate);
|
|
map.put("startDate", startDate);
|
|
map.put("endDate", endDate);
|
|
map.put("endDate", endDate);
|
|
list.add(map);
|
|
list.add(map);
|
|
} else {
|
|
} else {
|
|
while (DateUtils.compareDate(startDate, splitDate) < 0 || DateUtils.compareDate(startDate, endDate) <= 0) {
|
|
while (DateUtils.compareDate(startDate, splitDate) < 0 || DateUtils.compareDate(startDate, endDate) <= 0) {
|
|
- Map<String, String> map = new HashMap<String, String>();
|
|
|
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
map.put("startDate", splitDate);
|
|
map.put("startDate", splitDate);
|
|
map.put("endDate", endDate);
|
|
map.put("endDate", endDate);
|
|
list.add(map);
|
|
list.add(map);
|
|
@@ -713,17 +664,17 @@ public class DateUtils extends PropertyEditorSupport {
|
|
}
|
|
}
|
|
|
|
|
|
public static List<Map<String, String>> getDateWeekRange(String startDate, String endDate) throws ParseException {
|
|
public static List<Map<String, String>> getDateWeekRange(String startDate, String endDate) throws ParseException {
|
|
- List<Map<String, String>> list = new ArrayList<Map<String, String>>();
|
|
|
|
|
|
+ List<Map<String, String>> list = new ArrayList<>();
|
|
String splitDate = DateUtils.addWeek(endDate, -1);
|
|
String splitDate = DateUtils.addWeek(endDate, -1);
|
|
splitDate = DateUtils.addDay(splitDate, 1);
|
|
splitDate = DateUtils.addDay(splitDate, 1);
|
|
if (DateUtils.compareDate(startDate, splitDate) >= 0) {
|
|
if (DateUtils.compareDate(startDate, splitDate) >= 0) {
|
|
- Map<String, String> map = new HashMap<String, String>();
|
|
|
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
map.put("startDate", startDate);
|
|
map.put("startDate", startDate);
|
|
map.put("endDate", endDate);
|
|
map.put("endDate", endDate);
|
|
list.add(map);
|
|
list.add(map);
|
|
} else {
|
|
} else {
|
|
while (DateUtils.compareDate(startDate, splitDate) < 0 || DateUtils.compareDate(startDate, endDate) <= 0) {
|
|
while (DateUtils.compareDate(startDate, splitDate) < 0 || DateUtils.compareDate(startDate, endDate) <= 0) {
|
|
- Map<String, String> map = new HashMap<String, String>();
|
|
|
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
map.put("startDate", splitDate);
|
|
map.put("startDate", splitDate);
|
|
map.put("endDate", endDate);
|
|
map.put("endDate", endDate);
|
|
list.add(map);
|
|
list.add(map);
|
|
@@ -738,17 +689,17 @@ public class DateUtils extends PropertyEditorSupport {
|
|
}
|
|
}
|
|
|
|
|
|
public static List<Map<String, String>> getDateMonthRange(String startDate, String endDate) throws ParseException {
|
|
public static List<Map<String, String>> getDateMonthRange(String startDate, String endDate) throws ParseException {
|
|
- List<Map<String, String>> list = new ArrayList<Map<String, String>>();
|
|
|
|
|
|
+ List<Map<String, String>> list = new ArrayList<>();
|
|
String splitDate = DateUtils.addMonth(endDate, -1);
|
|
String splitDate = DateUtils.addMonth(endDate, -1);
|
|
splitDate = DateUtils.addDay(splitDate, 1);
|
|
splitDate = DateUtils.addDay(splitDate, 1);
|
|
if (DateUtils.compareDate(startDate, splitDate) >= 0) {
|
|
if (DateUtils.compareDate(startDate, splitDate) >= 0) {
|
|
- Map<String, String> map = new HashMap<String, String>();
|
|
|
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
map.put("startDate", startDate);
|
|
map.put("startDate", startDate);
|
|
map.put("endDate", endDate);
|
|
map.put("endDate", endDate);
|
|
list.add(map);
|
|
list.add(map);
|
|
} else {
|
|
} else {
|
|
while (DateUtils.compareDate(startDate, splitDate) < 0 || DateUtils.compareDate(startDate, endDate) <= 0) {
|
|
while (DateUtils.compareDate(startDate, splitDate) < 0 || DateUtils.compareDate(startDate, endDate) <= 0) {
|
|
- Map<String, String> map = new HashMap<String, String>();
|
|
|
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
map.put("startDate", splitDate);
|
|
map.put("startDate", splitDate);
|
|
map.put("endDate", endDate);
|
|
map.put("endDate", endDate);
|
|
list.add(map);
|
|
list.add(map);
|
|
@@ -844,11 +795,10 @@ public class DateUtils extends PropertyEditorSupport {
|
|
|
|
|
|
public static Map<String, Object> getBeforeDate() {
|
|
public static Map<String, Object> getBeforeDate() {
|
|
Date dNow = new Date();
|
|
Date dNow = new Date();
|
|
- Date dBefore = new Date();
|
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
Calendar calendar = Calendar.getInstance();
|
|
calendar.setTime(dNow);
|
|
calendar.setTime(dNow);
|
|
calendar.add(Calendar.DAY_OF_MONTH, -1);
|
|
calendar.add(Calendar.DAY_OF_MONTH, -1);
|
|
- dBefore = calendar.getTime();
|
|
|
|
|
|
+ Date dBefore = calendar.getTime();
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
String defaultStartDate = sdf.format(dBefore);
|
|
String defaultStartDate = sdf.format(dBefore);
|
|
defaultStartDate = defaultStartDate + " 00:00:00";
|
|
defaultStartDate = defaultStartDate + " 00:00:00";
|
|
@@ -865,7 +815,6 @@ public class DateUtils extends PropertyEditorSupport {
|
|
* @param date 传入的初始日期
|
|
* @param date 传入的初始日期
|
|
* @param num 天数
|
|
* @param num 天数
|
|
* @return
|
|
* @return
|
|
- * @throws ParseException
|
|
|
|
*/
|
|
*/
|
|
public static String getAnotherDay(String format, String date, Integer num) {
|
|
public static String getAnotherDay(String format, String date, Integer num) {
|
|
|
|
|
|
@@ -914,8 +863,6 @@ public class DateUtils extends PropertyEditorSupport {
|
|
}
|
|
}
|
|
|
|
|
|
public static Map<String, Object> compareDate(String format, String date1, String date2) {
|
|
public static Map<String, Object> compareDate(String format, String date1, String date2) {
|
|
-
|
|
|
|
-
|
|
|
|
DateFormat df = new SimpleDateFormat(format);
|
|
DateFormat df = new SimpleDateFormat(format);
|
|
Map<String, Object> map = new HashMap<>();
|
|
Map<String, Object> map = new HashMap<>();
|
|
try {
|
|
try {
|
|
@@ -945,11 +892,9 @@ public class DateUtils extends PropertyEditorSupport {
|
|
* @throws ParseException
|
|
* @throws ParseException
|
|
*/
|
|
*/
|
|
public static String getYear(String format, String date) throws ParseException {
|
|
public static String getYear(String format, String date) throws ParseException {
|
|
-
|
|
|
|
SimpleDateFormat df = new SimpleDateFormat(format);
|
|
SimpleDateFormat df = new SimpleDateFormat(format);
|
|
Date parse = df.parse(date);
|
|
Date parse = df.parse(date);
|
|
return String.format("%tY", parse);
|
|
return String.format("%tY", parse);
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -975,7 +920,6 @@ public class DateUtils extends PropertyEditorSupport {
|
|
* @throws ParseException
|
|
* @throws ParseException
|
|
*/
|
|
*/
|
|
public static String getDay(String format, String date) throws ParseException {
|
|
public static String getDay(String format, String date) throws ParseException {
|
|
-
|
|
|
|
SimpleDateFormat df = new SimpleDateFormat(format);
|
|
SimpleDateFormat df = new SimpleDateFormat(format);
|
|
Date parse = df.parse(date);
|
|
Date parse = df.parse(date);
|
|
return String.format("%td", parse);
|
|
return String.format("%td", parse);
|
|
@@ -1016,7 +960,6 @@ public class DateUtils extends PropertyEditorSupport {
|
|
calendar.setTime(date);
|
|
calendar.setTime(date);
|
|
calendar.setFirstDayOfWeek(Calendar.FRIDAY);
|
|
calendar.setFirstDayOfWeek(Calendar.FRIDAY);
|
|
calendar.set(Calendar.DAY_OF_WEEK, Calendar.FRIDAY);
|
|
calendar.set(Calendar.DAY_OF_WEEK, Calendar.FRIDAY);
|
|
- DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
return calendar.getTime();
|
|
return calendar.getTime();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1026,13 +969,12 @@ public class DateUtils extends PropertyEditorSupport {
|
|
*/
|
|
*/
|
|
public static Map<String, Integer> getYearQuarter(Date date) {
|
|
public static Map<String, Integer> getYearQuarter(Date date) {
|
|
Map<String, Integer> dateMap = new HashMap<>();
|
|
Map<String, Integer> dateMap = new HashMap<>();
|
|
-
|
|
|
|
Calendar calendar = new GregorianCalendar();
|
|
Calendar calendar = new GregorianCalendar();
|
|
calendar.setTime(date);
|
|
calendar.setTime(date);
|
|
int originYear = calendar.get(Calendar.YEAR);
|
|
int originYear = calendar.get(Calendar.YEAR);
|
|
int originMonth = calendar.get(Calendar.MONTH);
|
|
int originMonth = calendar.get(Calendar.MONTH);
|
|
- int originQuarter = DateUtils.getQuarter(date); //本月所在季度(按照日期来的)
|
|
|
|
-
|
|
|
|
|
|
+ //本月所在季度(按照日期来的)
|
|
|
|
+ int originQuarter = DateUtils.getQuarter(date);
|
|
Calendar calendar1 = new GregorianCalendar();
|
|
Calendar calendar1 = new GregorianCalendar();
|
|
calendar1.setTime(date);
|
|
calendar1.setTime(date);
|
|
calendar1.setFirstDayOfWeek(Calendar.FRIDAY);
|
|
calendar1.setFirstDayOfWeek(Calendar.FRIDAY);
|
|
@@ -1054,7 +996,8 @@ public class DateUtils extends PropertyEditorSupport {
|
|
//如果本周第一天(周五)和当前天不在一个月内,说明周跨月了
|
|
//如果本周第一天(周五)和当前天不在一个月内,说明周跨月了
|
|
if (fridayMonth == originMonth && thursdayMonth == originMonth) {
|
|
if (fridayMonth == originMonth && thursdayMonth == originMonth) {
|
|
dateMap.put("year", originYear);
|
|
dateMap.put("year", originYear);
|
|
- dateMap.put("month", originMonth + 1); //最后一个月是11,应该+1
|
|
|
|
|
|
+ //最后一个月是11,应该+1
|
|
|
|
+ dateMap.put("month", originMonth + 1);
|
|
dateMap.put("quarter", originQuarter);
|
|
dateMap.put("quarter", originQuarter);
|
|
return dateMap;
|
|
return dateMap;
|
|
} else if (fridayYear < originYear || (fridayYear == originYear && fridayMonth < originMonth)) {
|
|
} else if (fridayYear < originYear || (fridayYear == originYear && fridayMonth < originMonth)) {
|
|
@@ -1248,14 +1191,10 @@ public class DateUtils extends PropertyEditorSupport {
|
|
startCalendar.setTime(start);
|
|
startCalendar.setTime(start);
|
|
GregorianCalendar endCalendar = new GregorianCalendar();
|
|
GregorianCalendar endCalendar = new GregorianCalendar();
|
|
endCalendar.setTime(end);
|
|
endCalendar.setTime(end);
|
|
-
|
|
|
|
int startYear = startCalendar.get(Calendar.YEAR);
|
|
int startYear = startCalendar.get(Calendar.YEAR);
|
|
int startMonth = startCalendar.get(Calendar.MONTH) + 1;
|
|
int startMonth = startCalendar.get(Calendar.MONTH) + 1;
|
|
- int startDay = startCalendar.get(Calendar.DAY_OF_MONTH);
|
|
|
|
int endYear = endCalendar.get(Calendar.YEAR);
|
|
int endYear = endCalendar.get(Calendar.YEAR);
|
|
int endMonth = endCalendar.get(Calendar.MONTH) + 1;
|
|
int endMonth = endCalendar.get(Calendar.MONTH) + 1;
|
|
- int endDay = endCalendar.get(Calendar.DAY_OF_MONTH);
|
|
|
|
-
|
|
|
|
return (endYear - startYear) * 12 + (endMonth - startMonth);
|
|
return (endYear - startYear) * 12 + (endMonth - startMonth);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1317,12 +1256,6 @@ public class DateUtils extends PropertyEditorSupport {
|
|
return (int) betweenDate;
|
|
return (int) betweenDate;
|
|
}
|
|
}
|
|
|
|
|
|
- public static Date addMonth(Date date) {
|
|
|
|
- Calendar calendar = Calendar.getInstance();//日历对象
|
|
|
|
- calendar.add(Calendar.MONTH, -1);//月份减一
|
|
|
|
- return calendar.getTime();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 判断两个日期间隔是否大于半年
|
|
* 判断两个日期间隔是否大于半年
|
|
*
|
|
*
|
|
@@ -1334,13 +1267,13 @@ public class DateUtils extends PropertyEditorSupport {
|
|
long time1 = c.getTimeInMillis();
|
|
long time1 = c.getTimeInMillis();
|
|
c.setTime(Objects.requireNonNull(parseDate(endDate, SystemDateConstant.yyyy_MM_dd)));
|
|
c.setTime(Objects.requireNonNull(parseDate(endDate, SystemDateConstant.yyyy_MM_dd)));
|
|
long time2 = c.getTimeInMillis();
|
|
long time2 = c.getTimeInMillis();
|
|
- long between_days = (time2 - time1) / (1000 * 3600 * 24);
|
|
|
|
- int day = Integer.parseInt(String.valueOf(between_days));
|
|
|
|
|
|
+ long betweenDays = (time2 - time1) / (1000 * 3600 * 24);
|
|
|
|
+ int day = Integer.parseInt(String.valueOf(betweenDays));
|
|
return day > 180;
|
|
return day > 180;
|
|
}
|
|
}
|
|
|
|
|
|
public static List<Date> findDates(Date dBegin, Date dEnd) {
|
|
public static List<Date> findDates(Date dBegin, Date dEnd) {
|
|
- List<Date> lDate = new ArrayList<Date>();
|
|
|
|
|
|
+ List<Date> lDate = new ArrayList<>();
|
|
lDate.add(dBegin);
|
|
lDate.add(dBegin);
|
|
Calendar calBegin = Calendar.getInstance();
|
|
Calendar calBegin = Calendar.getInstance();
|
|
// 使用给定的 Date 设置此 Calendar 的时间
|
|
// 使用给定的 Date 设置此 Calendar 的时间
|