| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- package com.kingdee.eas.custom.perfweb.util;
- import java.util.Calendar;
- /**
- * 类名称: ReportDateUtil
- * 功能描述: 报表日期工具
- * 创建日期: 2026-06-23
- * 作 者: 青梧
- * 版 本: 1.0
- */
- public final class ReportDateUtil {
- private ReportDateUtil() {
- }
- public static String getMonthStart(String year, int month) {
- return year + "-" + String.format("%02d", month) + "-01";
- }
- public static String getMonthEnd(String year, int month) {
- return year + "-" + String.format("%02d", month) + "-" + getLastDayOfMonth(Integer.parseInt(year), month);
- }
- public static String formatMonthLabel(String year, int month) {
- return year + "年" + month + "月";
- }
- public static String getLastDayOfMonth(int year, int month) {
- Calendar calendar = Calendar.getInstance();
- calendar.set(year, month - 1, 1);
- int lastDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
- return String.format("%02d", lastDay);
- }
- public static String getNextMonthStart(String year, int month) {
- if (month == 12) {
- return (Integer.parseInt(year) + 1) + "-01-01";
- }
- return year + "-" + String.format("%02d", month + 1) + "-01";
- }
- public static String formatMonthLabelFromDayKey(String dayKey) {
- if (dayKey == null || dayKey.length() < 7) {
- return dayKey;
- }
- String year = dayKey.substring(0, 4);
- int month = Integer.parseInt(dayKey.substring(5, 7));
- return formatMonthLabel(year, month);
- }
- }
|