From 3489fc2470fe53a1c4e967fcbaa168445f303276 Mon Sep 17 00:00:00 2001 From: Renpc-kilig <308442850@qq.com> Date: Tue, 5 Jan 2021 15:06:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E6=9C=9F=E5=B7=A5=E5=85=B7=E7=B1=BBbu?= =?UTF-8?q?g=E4=BF=AE=E6=94=B9=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/cm/bigdata/utils/DateUtils.java | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) 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