/** * 取得时间描述 日 mm月dd日 月 yy年mm月 季 yy年×季度(x=1/2/3/4) 年 yy年 * * @param granularity 粒度 * @param statisticDate 时间 * @return 时间对应粒度的描述 */ public String getTimedes2(String granularity, String statisticDate) { String timedes = ""; Date date = DateUtils.stringToDateShort(statisticDate); String year = "", month = "01", day = "01"; year = DateUtils.getYear(date).substring(2, 4); month = DateUtils.getMonth(date); day = DateUtils.getDay(date); if (granularity.equals("1")) { // 日 timedes = month + "月" + day + "日"; ; } else if (granularity.equals("4")) { // 月 timedes = year + "年" + month + "月"; } else if (granularity.equals("8")) { // 季 String quarter = month + "-" + day; if (quarter.equals("03-31")) { timedes = year + "年1季度"; } else if (quarter.equals("06-30")) { timedes = year + "年2季度"; } else if (quarter.equals("09-30")) { timedes = year + "年3季度"; } else if (quarter.equals("12-31")) { timedes = year + "年4季度"; } } else if (granularity.equals("32")) { // 年 timedes = year + "年"; } return timedes; }