Commit b454ba6d by guojx

好办小程序埋点趋势图时间补零修复

parent 07d06d2e
......@@ -4,7 +4,9 @@ import com.alibaba.fastjson.JSONObject;
import com.gic.commons.util.DataApiUtils;
import com.gic.commons.util.DateUtil;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
......@@ -21,10 +23,16 @@ public class DateExpandUtils {
if (dateType == null) {
dateType = 1;
}
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
Calendar calendar = Calendar.getInstance();
try {
switch (dateType) {
case 1:
list.add(startDate);
case 2:
case 3:
calendar.setTime(dateType == 1 ? df.parse(startDate) : df.parse(endDate));
calendar.add(Calendar.DAY_OF_YEAR, -29);
list = DateUtil.getBetweenDates(df.format(calendar.getTime()), startDate);
break;
case 4:
JSONObject jsonObject = new JSONObject();
......@@ -35,8 +43,17 @@ public class DateExpandUtils {
List<JSONObject> data = DataApiUtils.getPageList(res);
list = data.stream().map(e ->e.getString("weekYear")).collect(Collectors.toList());
break;
case 5:
//月
SimpleDateFormat monthFormat = new SimpleDateFormat("yyyy-MM");
calendar.setTime(df.parse(startDate));
calendar.add(Calendar.MONTH, -11);
for (int i = 1; i <= 12; i++) {
list.add(monthFormat.format(calendar.getTime()));
calendar.add(Calendar.MONTH, 1);
}
break;
default:
list = DateUtil.getBetweenDates(startDate, endDate);
}
} catch (Exception e) {
......
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