private String getCurentYearFistDay(){
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.DAY_OF_YEAR,1);
log.info("获取当年第一天={}" , simpleDateFormat.format(calendar.getTime()));
return simpleDateFormat.format(calendar.getTime());
}
private String getCurentMonthFistDay(){
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.DAY_OF_MONTH,1);
log.info("获取当月第一天={}" , simpleDateFormat.format(calendar.getTime()));
return simpleDateFormat.format(calendar.getTime());
}
private String getTodayFistTime(){
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY,0);
log.info("获取今天最早时间={}" , simpleDateFormat.format(calendar.getTime()));
return simpleDateFormat.format(calendar.getTime());
}
private String getYesTodayFistTime(){
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY,-1);
log.info("获取昨天最早时间={}" , simpleDateFormat.format(calendar.getTime()));
return simpleDateFormat.format(calendar.getTime());
}
private String getDateTimeFromDay(Integer day){
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DAY_OF_MONTH,-day);
log.info("获取day时间={}" , simpleDateFormat.format(calendar.getTime()));
return simpleDateFormat.format(calendar.getTime());
}
private String getDateTimeFromYear(Integer year){
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.YEAR,year);
calendar.set(Calendar.DAY_OF_YEAR,1);
log.info("获取day时间={}" , simpleDateFormat.format(calendar.getTime()));
return simpleDateFormat.format(calendar.getTime());
}
|