|
@ -11,6 +11,7 @@ package com.epmet.commons.tools.utils; |
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
import com.epmet.commons.tools.constant.StrConstant; |
|
|
import com.epmet.commons.tools.constant.StrConstant; |
|
|
import com.epmet.commons.tools.dto.form.TimeListResultDTO; |
|
|
import com.epmet.commons.tools.dto.form.TimeListResultDTO; |
|
|
|
|
|
import com.google.common.collect.Maps; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.joda.time.DateTime; |
|
|
import org.joda.time.DateTime; |
|
|
import org.joda.time.LocalDate; |
|
|
import org.joda.time.LocalDate; |
|
@ -917,4 +918,31 @@ public class DateUtils { |
|
|
return new SimpleDateFormat(DateUtils.DATE_PATTERN_YYYYMMDD).format(time); |
|
|
return new SimpleDateFormat(DateUtils.DATE_PATTERN_YYYYMMDD).format(time); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @Author sun |
|
|
|
|
|
* @Description 获取dateId对应上一个月过去12个月的monthId |
|
|
|
|
|
* dateId yyyymmdd |
|
|
|
|
|
* 20211201 -> 202012-202111的值 |
|
|
|
|
|
**/ |
|
|
|
|
|
public static LinkedHashMap<String,String> getXproSub(String dateId){ |
|
|
|
|
|
java.time.format.DateTimeFormatter fmt = java.time.format.DateTimeFormatter.ofPattern("yyyyMM"); |
|
|
|
|
|
LinkedHashMap<String,String> xAxis = new LinkedHashMap<>(); |
|
|
|
|
|
Calendar cal=Calendar.getInstance(); |
|
|
|
|
|
cal.setTime(DateUtils.parseDate(dateId, DateUtils.DATE_PATTERN_YYYYMMDD)); |
|
|
|
|
|
TimeZone tz = cal.getTimeZone(); |
|
|
|
|
|
ZoneId zid = tz == null ? ZoneId.systemDefault() : tz.toZoneId(); |
|
|
|
|
|
java.time.LocalDate today = java.time.LocalDateTime.ofInstant(cal.toInstant(), zid).toLocalDate(); |
|
|
|
|
|
//java.time.LocalDate today = java.time.LocalDate.now();
|
|
|
|
|
|
|
|
|
|
|
|
for(int i = NumConstant.TWELVE;i > NumConstant.ZERO; i--){ |
|
|
|
|
|
java.time.LocalDate localDate = today.minusMonths(i); |
|
|
|
|
|
String s = localDate.getMonth().getValue() + "月"; |
|
|
|
|
|
xAxis.put(localDate.format(fmt),s); |
|
|
|
|
|
} |
|
|
|
|
|
LinkedHashMap<String, String> result = Maps.newLinkedHashMap(); |
|
|
|
|
|
xAxis.entrySet().stream().sorted(Map.Entry.comparingByKey()) |
|
|
|
|
|
.forEachOrdered((e -> result.put(e.getKey(),e.getValue()))); |
|
|
|
|
|
return result; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|