| | |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.*; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | |
| | | public static DateTimeFormatter format_ymd_String = DateTimeFormatter.ofPattern("yyMMdd"); |
| | | public static SimpleDateFormat yyyyMM_format = new SimpleDateFormat("yyyy-MM"); |
| | | public static SimpleDateFormat format_yyymmdd = new SimpleDateFormat("yyyyMMdd"); |
| | | public static SimpleDateFormat format_yyyy = new SimpleDateFormat("yyyy"); |
| | | private static DateTimeFormatter format_ymdhmssss = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"); |
| | | private static DateTimeFormatter format_ymds = DateTimeFormatter.ofPattern("yyyyMMdd"); |
| | | private static DateTimeFormatter format_yms = DateTimeFormatter.ofPattern("yyyyMM"); |
| | |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | return sdf.format(calendar.getTime()) + " 23:59:59"; |
| | | } |
| | | /** |
| | | * 获取当前月最后一天 |
| | | * |
| | | * @return |
| | | */ |
| | | public static Date getLastDayOfMonth() { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | |
| | | calendar.add(Calendar.MONTH, 1); |
| | | |
| | | calendar.set(Calendar.DAY_OF_MONTH, 0); |
| | | // 格式化日期 |
| | | |
| | | return calendar.getTime(); |
| | | } |
| | | |
| | | /** |
| | | * 获取当前时间(年月日) |
| | |
| | | String lastMonthEndTime = yyyyMMdd_format.format(lastMonthEndDateCal.getTime()) + " 23:59:59"; |
| | | return stringToDateStandard(lastMonthEndTime); |
| | | } |
| | | |
| | | /** |
| | | * 获取近20天日期 |
| | | * @return 近20天日期 |
| | | */ |
| | | public static List<Date> getOldDays() { |
| | | List<Date> dates = new ArrayList<>(); |
| | | Date date = new Date(); |
| | | for (int i = 19; i >= 0; i--) { |
| | | Date date1 = DateUtils.addDay(date, -i); |
| | | dates.add(date1); |
| | | } |
| | | return dates; |
| | | } |
| | | } |