Java 日期 —— 获取上个月的指定日期、当前月份、上一个月份

    public Map<String, String> getParamMap() {
        Calendar c = Calendar.getInstance();
        SimpleDateFormat simpleDateFormatMonth = new SimpleDateFormat("yyyy-MM");
        String curMonth = simpleDateFormatMonth.format(c.getTime());

        SimpleDateFormat simpleDateFormatDay = new SimpleDateFormat("yyyy-MM-26");
        String endDate = simpleDateFormatDay.format(c.getTime());

        c.add(Calendar.MONTH, -1);
        String startDate = simpleDateFormatDay.format(c.getTime());
        Map<String, String> map = new HashMap<>();
        map.put(BalanceAccountConst.CUR_MONTH, curMonth);
        map.put(BalanceAccountConst.START_DATE, startDate);
        map.put(BalanceAccountConst.END_DATE, endDate);
        return map;
    }

你可能感兴趣的:(Java基础)