• jodatime 时间比较


    public ArrayList<CalcPeriod> getCalcPeriods() {
            DateTime now = DateTime.now();
            DateTime.Property year = now.year();
    
            DateTimeFormatter yyyyMMdd = DateTimeFormat.forPattern("yyyyMMdd");
            DateTime season1 = DateTime.parse(year.get() + Constant.SEASON1,yyyyMMdd);
            DateTime season2 = DateTime.parse(year.get() + Constant.SEASON2,yyyyMMdd);
            DateTime season3 = DateTime.parse(year.get() + Constant.SEASON3,yyyyMMdd);
            DateTime season4 = DateTime.parse(year.get() + Constant.SEASON4,yyyyMMdd);
            //2.1 今年
            ArrayList<CalcPeriod> currentYearList = new ArrayList<>();
            if (now.isBefore(season1)){
    
            }else if (now.isAfter(season1) && now.isBefore(season2)){
                currentYearList.add(new CalcPeriod(year.get(),"1"));
            }else if (now.isAfter(season2) && now.isBefore(season3)) {
                currentYearList.add(new CalcPeriod(year.get(), "2"));
            }else if (now.isAfter(season3) && now.isBefore(season4)) {
                currentYearList.add(new CalcPeriod(year.get(), "3"));
            }
            //2.2 去年
            ArrayList<CalcPeriod> beforeCurrentYearList = new ArrayList<>();
            for (int i = 2012; i <= year.get() - 1; i++){
                for (int j = 1; j <= 4; j++){
                    beforeCurrentYearList.add(new CalcPeriod(i, String.valueOf(j)));
                }
            }
            ArrayList<CalcPeriod> totalList = new ArrayList<>();
            totalList.addAll(currentYearList);
            totalList.addAll(beforeCurrentYearList);
            return totalList;
        }
    
    public class CalcPeriod
    {
        private int year;
        private String period;
    
        public CalcPeriod(int year, String period) {
            this.year = year;
            this.period = period;
        }
    
        public CalcPeriod() {
        }
    
        public int getYear()
        {
            return this.year;
        }
    
        public void setYear(int year) {
            this.year = year;
        }
    
    }
    
    
        public static final String SEASON1 = "0331";
        public static final String SEASON2 = "0630";
        public static final String SEASON3 = "0930";
        public static final String SEASON4 = "1231";
  • 相关阅读:
    vue学习记录(四)---router的运用
    node.js 框架express关于报错页面的配置
    node.js 的热更新
    yii2 Menu组件的使用
    node.js 框架express有关于router的运用
    node.js 的页面渲染方法ejs
    什么是mybatis
    如何清除maven中下载失败的包
    hibernate 执行步骤
    什么是ORM
  • 原文地址:https://www.cnblogs.com/grey-wolf/p/7009641.html
Copyright © 2020-2023  润新知