diff --git a/src/main/java/com/cm/bigdata/utils/DateUtils.java b/src/main/java/com/cm/bigdata/utils/DateUtils.java index 6a1a39d..5ca0630 100644 --- a/src/main/java/com/cm/bigdata/utils/DateUtils.java +++ b/src/main/java/com/cm/bigdata/utils/DateUtils.java @@ -69,20 +69,18 @@ public class DateUtils{ Calendar startCalendar = Calendar.getInstance(); Calendar endCalendar = Calendar.getInstance(); if(quarter == 1) { - startCalendar.set(year, 1, 1, 00, 00, 00); - endCalendar.set(year, 3,31, 23,59,59); + startCalendar.set(year, 1-1, 1, 00, 00, 00); + endCalendar.set(year, 3-1,31, 23,59,59); }else if(quarter == 2) { - startCalendar.set(year, 4, 1, 00, 00, 00); - endCalendar.set(year, 6,30, 23,59,59); + startCalendar.set(year, 4-1, 1, 00, 00, 00); + endCalendar.set(year, 6-1,30, 23,59,59); }else if(quarter == 3) { - startCalendar.set(year, 7, 1, 00, 00, 00); - endCalendar.set(year, 9,30, 23,59,59); + startCalendar.set(year, 7-1, 1, 00, 00, 00); + endCalendar.set(year, 9-1,30, 23,59,59); }else { - startCalendar.set(year, 10, 1, 00, 00, 00); - endCalendar.set(year, 12,31, 23,59,59); + startCalendar.set(year, 10-1, 1, 00, 00, 00); + endCalendar.set(year, 12-1,31, 23,59,59); } - setMinTime(startCalendar); - setMaxTime(endCalendar); return new DateRange(startCalendar.getTime(), endCalendar.getTime()); } @@ -211,5 +209,10 @@ public class DateUtils{ DateRange lastQuarter = getLastQuarter(); //System.out.println("上个季度的时间范围: "+DateUtilsTemp.format(lastQuarter.getStart())+" - "+DateUtilsTemp.format(lastQuarter.getEnd())); + DateRange dateRange = returnQuarterCurrent(2020, 5); + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + System.out.println(df.format(dateRange.getStart())); + System.out.println(df.format(dateRange.getEnd())); + } } \ No newline at end of file