基于Java的周次生成工具类实现

摘要:

本文介绍了一个基于Java的周次生成工具,用于根据指定的年份和周次类型(自然周或财务周)生成连续的周次列表数据。

需求描述:

根据周次类型,生成连续的周次列表数据。

周次类型分2种:

  1. 自然周:周一至周日
  2. 财务周:周五至下周四

特殊要求:

  • 按某年第一个周止日(类型为自然周时,是某年第一个周日),计算得到某年的第一周。
  • 按周止日算年份、月份;若周起日是当年,而周止日是下一年,则对应周算入下一年的第一周。

最终效果展示:

 效果:(自然周)

效果:(财务周)

实现步骤:

1.定义周次类型枚举

包括自然周和财务周,并指定了每种周次的起始和结束日期对应的星期几。

import java.util.Calendar;/**周次类型*/
public enum WeekKindEnum {// 周一到周日G("G", Calendar.MONDAY,Calendar.SUNDAY,"自然周"),// 周五到下周四F("F",Calendar.FRIDAY,Calendar.THURSDAY,"财务周");WeekKindEnum(String code, int beginNum, int endNum, String desc) {this.code = code;this.beginNum = beginNum;this.endNum = endNum;this.desc = desc;}private String code;private int beginNum;private int endNum;private String desc;public String getCode() {return code;}public int getBeginNum() {return beginNum;}public int getEndNum() {return endNum;}public String getDesc() {return desc;}
}

2.定义周次实体

用于存储周次的相关信息,如年份、周起止日期、周次、周描述、所属年月等。

import java.text.SimpleDateFormat;
import java.util.Date;/*** @ClassName WeekEntity* @Description 周次* @Date 2024/11/8 23:29* @Author yqwang*/
public class WeekEntity {/*年*/private String year;/*周起*/private Date beginDate;/*周止*/private Date endDate;/*周次(某年第几周)*/private int week;/*周描述*/private String weekDesc;/*周次(某月第几周)*/private int weekMonth;/*所属年月yyyy-MM*/private String yearMonth;/*所属年月yyyy-MM-01*/private Date yearMonthDate;/*类型:G(general)自然周F(finance)财务周*/private String kindId;public String getYear() {return year;}public void setYear(String year) {this.year = year;}public Date getBeginDate() {return beginDate;}public void setBeginDate(Date beginDate) {this.beginDate = beginDate;}public Date getEndDate() {return endDate;}public void setEndDate(Date endDate) {this.endDate = endDate;}public int getWeek() {return week;}public void setWeek(int week) {this.week = week;}public String getWeekDesc() {return weekDesc;}public void setWeekDesc(String weekDesc) {this.weekDesc = weekDesc;}public int getWeekMonth() {return weekMonth;}public void setWeekMonth(int weekMonth) {this.weekMonth = weekMonth;}public String getYearMonth() {return yearMonth;}public void setYearMonth(String yearMonth) {this.yearMonth = yearMonth;}public Date getYearMonthDate() {return yearMonthDate;}public void setYearMonthDate(Date yearMonthDate) {this.yearMonthDate = yearMonthDate;}public String getKindId() {return kindId;}public void setKindId(String kindId) {this.kindId = kindId;}@Overridepublic String toString() {return "WeekEntity{" +"year='" + year + '\'' +", beginDate=" + formatDate(beginDate) +", endDate=" + formatDate(endDate) +", week=" + week +", weekDesc='" + weekDesc + '\'' +", weekMonth=" + weekMonth +", yearMonth='" + yearMonth + '\'' +", yearMonthDate=" + formatDate(yearMonthDate) +", kindId='" + kindId + '\'' +'}';}private static String formatDate(Date date) {SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");return sdf.format(date);}
}

3.编写生成工具类

编写了生成工具类WeekOfMonthCalcUtil,其中包含了generateWeeks方法,用于根据年份和周次类型生成周次列表。该方法首先获取第一周的起止日期,然后循环得到每年的每周,并设置周次实体的其他属性值。

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;/*** @ClassName WeekOfMonthCalcUtil* @Description 用于生成年份的周次(自然周、财务周)信息* @Date 2024/11/8 16:41* @Author yqwang*/
public class WeekOfMonthCalcUtil {public static void main(String[] args) {// 自然周List<WeekEntity> weeks = generateWeeks(2023, WeekKindEnum.G);weeks.addAll(generateWeeks(2024, WeekKindEnum.G));// 还需要财务周? // weeks.addAll(generateWeeks(2024, WeekKindEnum.F));// 打印结果for (WeekEntity week : weeks) {System.out.println(week);}}/*** @Title:generateWeeks* @param year 需要生成周次的年份* @param weekKindEnum 周次类型* @return 周次列表*/public static List<WeekEntity> generateWeeks(int year, WeekKindEnum weekKindEnum) {List<WeekEntity> weeks = new ArrayList<>(53);// 1.获取第一周的起止日期Calendar weekStart = getFirstWeekStart(year, weekKindEnum);// 今年的第几周int yearWeek = 1;while (weekStart.get(Calendar.YEAR) <= year){// 2.循环得到今年的每周,终止条件:开始年份<=目标年份WeekEntity row = new WeekEntity();row.setYear(String.valueOf(year));row.setBeginDate(weekStart.getTime());// 周止Calendar weekEnd = (Calendar) weekStart.clone();weekEnd.add(Calendar.DAY_OF_YEAR, 6);row.setEndDate(weekEnd.getTime());if(weekEnd.get(Calendar.YEAR) > year){// 周止是下一年,则退出(会算到下一年的第一周)break;}// 设置其他属性值row.setWeek(yearWeek);// 第1周(24.12.30~25.01.05)row.setWeekDesc(String.format("第%s周(%s~%s)",yearWeek,formatDate(row.getBeginDate(),"yy.MM.dd"),formatDate(row.getEndDate(),"yy.MM.dd")));// (正常以[周止]判断所属月;特殊:止是下一年,则以[周起判断所属月])Calendar belongDate = weekEnd;if(weekEnd.get(Calendar.YEAR) > year){belongDate = weekStart;}// 所属年月yyyy-MMrow.setYearMonth(formatDate(belongDate,"yyyy-MM"));// 所属年月yyyy-MM-01row.setYearMonthDate(truncDate(belongDate,"yyyy-MM"));// 所属周的当月第几周(若周止所在月天>=7,则周次-1)int dayOfWeek = weekEnd.get(Calendar.DAY_OF_MONTH);int weekMonth = (int) Math.floor((dayOfWeek-0.1)/7)+1;row.setWeekMonth(weekMonth);// 类型row.setKindId(weekKindEnum.getCode());weeks.add(row);// 3.周+1yearWeek ++;weekStart.add(Calendar.DAY_OF_YEAR, 7);}return weeks;}/**返回yyyy-MM-dd格式*/@SuppressWarnings("unused")private static String formatDate(Calendar calendar) {return formatDate(calendar.getTime());}/**返回yyyy-MM-dd格式*/private static String formatDate(Date date) {return formatDate(date,"yyyy-MM-dd");}/**返回指定格式*/private static String formatDate(Calendar calendar,String pattern){return formatDate(calendar.getTime(),pattern);}/**返回指定格式*/private static String formatDate(Date date,String pattern){if (date == null ) {throw new IllegalArgumentException("Date and format must not be null");}SimpleDateFormat sdf = new SimpleDateFormat(pattern);return sdf.format(date);}/**日期截取*/private static Date truncDate(Calendar calendar,String pattern){return truncDate(calendar.getTime(),pattern);}/**日期截取*/private static Date truncDate(Date date,String pattern){String dateStr = formatDate(date,pattern);DateFormat df = new SimpleDateFormat(pattern);try {return df.parse(dateStr);} catch (ParseException e) {e.printStackTrace();}return null;}/*** 获取某年第一个的周起日* 说明:通过某年第一个周止,往前推6天,即可得到周起日* */private static Calendar getFirstWeekStart(int year, WeekKindEnum weekKindEnum) {// yyyy-01-01Calendar end = Calendar.getInstance();end.set(year, Calendar.JANUARY, 1);// 1.拿到某年第一个周止while(true){// 2.当前是否是周止,不是则加1天,继续判断if(end.get(Calendar.DAY_OF_WEEK)== weekKindEnum.getEndNum()){break;}// +1天end.add(Calendar.DAY_OF_MONTH, 1);}// 3.返回周起日end.add(Calendar.DAY_OF_YEAR, -6);return end;}}

4.main()方法运行效果测试

WeekEntity{year='2023', beginDate=2022-12-26, endDate=2023-01-01, week=1, weekDesc='第1周(22.12.26~23.01.01)', weekMonth=1, yearMonth='2023-01', yearMonthDate=2023-01-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-01-02, endDate=2023-01-08, week=2, weekDesc='第2周(23.01.02~23.01.08)', weekMonth=2, yearMonth='2023-01', yearMonthDate=2023-01-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-01-09, endDate=2023-01-15, week=3, weekDesc='第3周(23.01.09~23.01.15)', weekMonth=3, yearMonth='2023-01', yearMonthDate=2023-01-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-01-16, endDate=2023-01-22, week=4, weekDesc='第4周(23.01.16~23.01.22)', weekMonth=4, yearMonth='2023-01', yearMonthDate=2023-01-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-01-23, endDate=2023-01-29, week=5, weekDesc='第5周(23.01.23~23.01.29)', weekMonth=5, yearMonth='2023-01', yearMonthDate=2023-01-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-01-30, endDate=2023-02-05, week=6, weekDesc='第6周(23.01.30~23.02.05)', weekMonth=1, yearMonth='2023-02', yearMonthDate=2023-02-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-02-06, endDate=2023-02-12, week=7, weekDesc='第7周(23.02.06~23.02.12)', weekMonth=2, yearMonth='2023-02', yearMonthDate=2023-02-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-02-13, endDate=2023-02-19, week=8, weekDesc='第8周(23.02.13~23.02.19)', weekMonth=3, yearMonth='2023-02', yearMonthDate=2023-02-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-02-20, endDate=2023-02-26, week=9, weekDesc='第9周(23.02.20~23.02.26)', weekMonth=4, yearMonth='2023-02', yearMonthDate=2023-02-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-02-27, endDate=2023-03-05, week=10, weekDesc='第10周(23.02.27~23.03.05)', weekMonth=1, yearMonth='2023-03', yearMonthDate=2023-03-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-03-06, endDate=2023-03-12, week=11, weekDesc='第11周(23.03.06~23.03.12)', weekMonth=2, yearMonth='2023-03', yearMonthDate=2023-03-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-03-13, endDate=2023-03-19, week=12, weekDesc='第12周(23.03.13~23.03.19)', weekMonth=3, yearMonth='2023-03', yearMonthDate=2023-03-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-03-20, endDate=2023-03-26, week=13, weekDesc='第13周(23.03.20~23.03.26)', weekMonth=4, yearMonth='2023-03', yearMonthDate=2023-03-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-03-27, endDate=2023-04-02, week=14, weekDesc='第14周(23.03.27~23.04.02)', weekMonth=1, yearMonth='2023-04', yearMonthDate=2023-04-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-04-03, endDate=2023-04-09, week=15, weekDesc='第15周(23.04.03~23.04.09)', weekMonth=2, yearMonth='2023-04', yearMonthDate=2023-04-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-04-10, endDate=2023-04-16, week=16, weekDesc='第16周(23.04.10~23.04.16)', weekMonth=3, yearMonth='2023-04', yearMonthDate=2023-04-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-04-17, endDate=2023-04-23, week=17, weekDesc='第17周(23.04.17~23.04.23)', weekMonth=4, yearMonth='2023-04', yearMonthDate=2023-04-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-04-24, endDate=2023-04-30, week=18, weekDesc='第18周(23.04.24~23.04.30)', weekMonth=5, yearMonth='2023-04', yearMonthDate=2023-04-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-05-01, endDate=2023-05-07, week=19, weekDesc='第19周(23.05.01~23.05.07)', weekMonth=1, yearMonth='2023-05', yearMonthDate=2023-05-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-05-08, endDate=2023-05-14, week=20, weekDesc='第20周(23.05.08~23.05.14)', weekMonth=2, yearMonth='2023-05', yearMonthDate=2023-05-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-05-15, endDate=2023-05-21, week=21, weekDesc='第21周(23.05.15~23.05.21)', weekMonth=3, yearMonth='2023-05', yearMonthDate=2023-05-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-05-22, endDate=2023-05-28, week=22, weekDesc='第22周(23.05.22~23.05.28)', weekMonth=4, yearMonth='2023-05', yearMonthDate=2023-05-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-05-29, endDate=2023-06-04, week=23, weekDesc='第23周(23.05.29~23.06.04)', weekMonth=1, yearMonth='2023-06', yearMonthDate=2023-06-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-06-05, endDate=2023-06-11, week=24, weekDesc='第24周(23.06.05~23.06.11)', weekMonth=2, yearMonth='2023-06', yearMonthDate=2023-06-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-06-12, endDate=2023-06-18, week=25, weekDesc='第25周(23.06.12~23.06.18)', weekMonth=3, yearMonth='2023-06', yearMonthDate=2023-06-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-06-19, endDate=2023-06-25, week=26, weekDesc='第26周(23.06.19~23.06.25)', weekMonth=4, yearMonth='2023-06', yearMonthDate=2023-06-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-06-26, endDate=2023-07-02, week=27, weekDesc='第27周(23.06.26~23.07.02)', weekMonth=1, yearMonth='2023-07', yearMonthDate=2023-07-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-07-03, endDate=2023-07-09, week=28, weekDesc='第28周(23.07.03~23.07.09)', weekMonth=2, yearMonth='2023-07', yearMonthDate=2023-07-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-07-10, endDate=2023-07-16, week=29, weekDesc='第29周(23.07.10~23.07.16)', weekMonth=3, yearMonth='2023-07', yearMonthDate=2023-07-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-07-17, endDate=2023-07-23, week=30, weekDesc='第30周(23.07.17~23.07.23)', weekMonth=4, yearMonth='2023-07', yearMonthDate=2023-07-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-07-24, endDate=2023-07-30, week=31, weekDesc='第31周(23.07.24~23.07.30)', weekMonth=5, yearMonth='2023-07', yearMonthDate=2023-07-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-07-31, endDate=2023-08-06, week=32, weekDesc='第32周(23.07.31~23.08.06)', weekMonth=1, yearMonth='2023-08', yearMonthDate=2023-08-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-08-07, endDate=2023-08-13, week=33, weekDesc='第33周(23.08.07~23.08.13)', weekMonth=2, yearMonth='2023-08', yearMonthDate=2023-08-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-08-14, endDate=2023-08-20, week=34, weekDesc='第34周(23.08.14~23.08.20)', weekMonth=3, yearMonth='2023-08', yearMonthDate=2023-08-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-08-21, endDate=2023-08-27, week=35, weekDesc='第35周(23.08.21~23.08.27)', weekMonth=4, yearMonth='2023-08', yearMonthDate=2023-08-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-08-28, endDate=2023-09-03, week=36, weekDesc='第36周(23.08.28~23.09.03)', weekMonth=1, yearMonth='2023-09', yearMonthDate=2023-09-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-09-04, endDate=2023-09-10, week=37, weekDesc='第37周(23.09.04~23.09.10)', weekMonth=2, yearMonth='2023-09', yearMonthDate=2023-09-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-09-11, endDate=2023-09-17, week=38, weekDesc='第38周(23.09.11~23.09.17)', weekMonth=3, yearMonth='2023-09', yearMonthDate=2023-09-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-09-18, endDate=2023-09-24, week=39, weekDesc='第39周(23.09.18~23.09.24)', weekMonth=4, yearMonth='2023-09', yearMonthDate=2023-09-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-09-25, endDate=2023-10-01, week=40, weekDesc='第40周(23.09.25~23.10.01)', weekMonth=1, yearMonth='2023-10', yearMonthDate=2023-10-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-10-02, endDate=2023-10-08, week=41, weekDesc='第41周(23.10.02~23.10.08)', weekMonth=2, yearMonth='2023-10', yearMonthDate=2023-10-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-10-09, endDate=2023-10-15, week=42, weekDesc='第42周(23.10.09~23.10.15)', weekMonth=3, yearMonth='2023-10', yearMonthDate=2023-10-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-10-16, endDate=2023-10-22, week=43, weekDesc='第43周(23.10.16~23.10.22)', weekMonth=4, yearMonth='2023-10', yearMonthDate=2023-10-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-10-23, endDate=2023-10-29, week=44, weekDesc='第44周(23.10.23~23.10.29)', weekMonth=5, yearMonth='2023-10', yearMonthDate=2023-10-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-10-30, endDate=2023-11-05, week=45, weekDesc='第45周(23.10.30~23.11.05)', weekMonth=1, yearMonth='2023-11', yearMonthDate=2023-11-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-11-06, endDate=2023-11-12, week=46, weekDesc='第46周(23.11.06~23.11.12)', weekMonth=2, yearMonth='2023-11', yearMonthDate=2023-11-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-11-13, endDate=2023-11-19, week=47, weekDesc='第47周(23.11.13~23.11.19)', weekMonth=3, yearMonth='2023-11', yearMonthDate=2023-11-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-11-20, endDate=2023-11-26, week=48, weekDesc='第48周(23.11.20~23.11.26)', weekMonth=4, yearMonth='2023-11', yearMonthDate=2023-11-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-11-27, endDate=2023-12-03, week=49, weekDesc='第49周(23.11.27~23.12.03)', weekMonth=1, yearMonth='2023-12', yearMonthDate=2023-12-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-12-04, endDate=2023-12-10, week=50, weekDesc='第50周(23.12.04~23.12.10)', weekMonth=2, yearMonth='2023-12', yearMonthDate=2023-12-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-12-11, endDate=2023-12-17, week=51, weekDesc='第51周(23.12.11~23.12.17)', weekMonth=3, yearMonth='2023-12', yearMonthDate=2023-12-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-12-18, endDate=2023-12-24, week=52, weekDesc='第52周(23.12.18~23.12.24)', weekMonth=4, yearMonth='2023-12', yearMonthDate=2023-12-01, kindId='G'}
WeekEntity{year='2023', beginDate=2023-12-25, endDate=2023-12-31, week=53, weekDesc='第53周(23.12.25~23.12.31)', weekMonth=5, yearMonth='2023-12', yearMonthDate=2023-12-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-01-01, endDate=2024-01-07, week=1, weekDesc='第1周(24.01.01~24.01.07)', weekMonth=1, yearMonth='2024-01', yearMonthDate=2024-01-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-01-08, endDate=2024-01-14, week=2, weekDesc='第2周(24.01.08~24.01.14)', weekMonth=2, yearMonth='2024-01', yearMonthDate=2024-01-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-01-15, endDate=2024-01-21, week=3, weekDesc='第3周(24.01.15~24.01.21)', weekMonth=3, yearMonth='2024-01', yearMonthDate=2024-01-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-01-22, endDate=2024-01-28, week=4, weekDesc='第4周(24.01.22~24.01.28)', weekMonth=4, yearMonth='2024-01', yearMonthDate=2024-01-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-01-29, endDate=2024-02-04, week=5, weekDesc='第5周(24.01.29~24.02.04)', weekMonth=1, yearMonth='2024-02', yearMonthDate=2024-02-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-02-05, endDate=2024-02-11, week=6, weekDesc='第6周(24.02.05~24.02.11)', weekMonth=2, yearMonth='2024-02', yearMonthDate=2024-02-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-02-12, endDate=2024-02-18, week=7, weekDesc='第7周(24.02.12~24.02.18)', weekMonth=3, yearMonth='2024-02', yearMonthDate=2024-02-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-02-19, endDate=2024-02-25, week=8, weekDesc='第8周(24.02.19~24.02.25)', weekMonth=4, yearMonth='2024-02', yearMonthDate=2024-02-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-02-26, endDate=2024-03-03, week=9, weekDesc='第9周(24.02.26~24.03.03)', weekMonth=1, yearMonth='2024-03', yearMonthDate=2024-03-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-03-04, endDate=2024-03-10, week=10, weekDesc='第10周(24.03.04~24.03.10)', weekMonth=2, yearMonth='2024-03', yearMonthDate=2024-03-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-03-11, endDate=2024-03-17, week=11, weekDesc='第11周(24.03.11~24.03.17)', weekMonth=3, yearMonth='2024-03', yearMonthDate=2024-03-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-03-18, endDate=2024-03-24, week=12, weekDesc='第12周(24.03.18~24.03.24)', weekMonth=4, yearMonth='2024-03', yearMonthDate=2024-03-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-03-25, endDate=2024-03-31, week=13, weekDesc='第13周(24.03.25~24.03.31)', weekMonth=5, yearMonth='2024-03', yearMonthDate=2024-03-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-04-01, endDate=2024-04-07, week=14, weekDesc='第14周(24.04.01~24.04.07)', weekMonth=1, yearMonth='2024-04', yearMonthDate=2024-04-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-04-08, endDate=2024-04-14, week=15, weekDesc='第15周(24.04.08~24.04.14)', weekMonth=2, yearMonth='2024-04', yearMonthDate=2024-04-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-04-15, endDate=2024-04-21, week=16, weekDesc='第16周(24.04.15~24.04.21)', weekMonth=3, yearMonth='2024-04', yearMonthDate=2024-04-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-04-22, endDate=2024-04-28, week=17, weekDesc='第17周(24.04.22~24.04.28)', weekMonth=4, yearMonth='2024-04', yearMonthDate=2024-04-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-04-29, endDate=2024-05-05, week=18, weekDesc='第18周(24.04.29~24.05.05)', weekMonth=1, yearMonth='2024-05', yearMonthDate=2024-05-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-05-06, endDate=2024-05-12, week=19, weekDesc='第19周(24.05.06~24.05.12)', weekMonth=2, yearMonth='2024-05', yearMonthDate=2024-05-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-05-13, endDate=2024-05-19, week=20, weekDesc='第20周(24.05.13~24.05.19)', weekMonth=3, yearMonth='2024-05', yearMonthDate=2024-05-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-05-20, endDate=2024-05-26, week=21, weekDesc='第21周(24.05.20~24.05.26)', weekMonth=4, yearMonth='2024-05', yearMonthDate=2024-05-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-05-27, endDate=2024-06-02, week=22, weekDesc='第22周(24.05.27~24.06.02)', weekMonth=1, yearMonth='2024-06', yearMonthDate=2024-06-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-06-03, endDate=2024-06-09, week=23, weekDesc='第23周(24.06.03~24.06.09)', weekMonth=2, yearMonth='2024-06', yearMonthDate=2024-06-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-06-10, endDate=2024-06-16, week=24, weekDesc='第24周(24.06.10~24.06.16)', weekMonth=3, yearMonth='2024-06', yearMonthDate=2024-06-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-06-17, endDate=2024-06-23, week=25, weekDesc='第25周(24.06.17~24.06.23)', weekMonth=4, yearMonth='2024-06', yearMonthDate=2024-06-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-06-24, endDate=2024-06-30, week=26, weekDesc='第26周(24.06.24~24.06.30)', weekMonth=5, yearMonth='2024-06', yearMonthDate=2024-06-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-07-01, endDate=2024-07-07, week=27, weekDesc='第27周(24.07.01~24.07.07)', weekMonth=1, yearMonth='2024-07', yearMonthDate=2024-07-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-07-08, endDate=2024-07-14, week=28, weekDesc='第28周(24.07.08~24.07.14)', weekMonth=2, yearMonth='2024-07', yearMonthDate=2024-07-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-07-15, endDate=2024-07-21, week=29, weekDesc='第29周(24.07.15~24.07.21)', weekMonth=3, yearMonth='2024-07', yearMonthDate=2024-07-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-07-22, endDate=2024-07-28, week=30, weekDesc='第30周(24.07.22~24.07.28)', weekMonth=4, yearMonth='2024-07', yearMonthDate=2024-07-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-07-29, endDate=2024-08-04, week=31, weekDesc='第31周(24.07.29~24.08.04)', weekMonth=1, yearMonth='2024-08', yearMonthDate=2024-08-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-08-05, endDate=2024-08-11, week=32, weekDesc='第32周(24.08.05~24.08.11)', weekMonth=2, yearMonth='2024-08', yearMonthDate=2024-08-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-08-12, endDate=2024-08-18, week=33, weekDesc='第33周(24.08.12~24.08.18)', weekMonth=3, yearMonth='2024-08', yearMonthDate=2024-08-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-08-19, endDate=2024-08-25, week=34, weekDesc='第34周(24.08.19~24.08.25)', weekMonth=4, yearMonth='2024-08', yearMonthDate=2024-08-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-08-26, endDate=2024-09-01, week=35, weekDesc='第35周(24.08.26~24.09.01)', weekMonth=1, yearMonth='2024-09', yearMonthDate=2024-09-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-09-02, endDate=2024-09-08, week=36, weekDesc='第36周(24.09.02~24.09.08)', weekMonth=2, yearMonth='2024-09', yearMonthDate=2024-09-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-09-09, endDate=2024-09-15, week=37, weekDesc='第37周(24.09.09~24.09.15)', weekMonth=3, yearMonth='2024-09', yearMonthDate=2024-09-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-09-16, endDate=2024-09-22, week=38, weekDesc='第38周(24.09.16~24.09.22)', weekMonth=4, yearMonth='2024-09', yearMonthDate=2024-09-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-09-23, endDate=2024-09-29, week=39, weekDesc='第39周(24.09.23~24.09.29)', weekMonth=5, yearMonth='2024-09', yearMonthDate=2024-09-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-09-30, endDate=2024-10-06, week=40, weekDesc='第40周(24.09.30~24.10.06)', weekMonth=1, yearMonth='2024-10', yearMonthDate=2024-10-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-10-07, endDate=2024-10-13, week=41, weekDesc='第41周(24.10.07~24.10.13)', weekMonth=2, yearMonth='2024-10', yearMonthDate=2024-10-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-10-14, endDate=2024-10-20, week=42, weekDesc='第42周(24.10.14~24.10.20)', weekMonth=3, yearMonth='2024-10', yearMonthDate=2024-10-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-10-21, endDate=2024-10-27, week=43, weekDesc='第43周(24.10.21~24.10.27)', weekMonth=4, yearMonth='2024-10', yearMonthDate=2024-10-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-10-28, endDate=2024-11-03, week=44, weekDesc='第44周(24.10.28~24.11.03)', weekMonth=1, yearMonth='2024-11', yearMonthDate=2024-11-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-11-04, endDate=2024-11-10, week=45, weekDesc='第45周(24.11.04~24.11.10)', weekMonth=2, yearMonth='2024-11', yearMonthDate=2024-11-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-11-11, endDate=2024-11-17, week=46, weekDesc='第46周(24.11.11~24.11.17)', weekMonth=3, yearMonth='2024-11', yearMonthDate=2024-11-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-11-18, endDate=2024-11-24, week=47, weekDesc='第47周(24.11.18~24.11.24)', weekMonth=4, yearMonth='2024-11', yearMonthDate=2024-11-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-11-25, endDate=2024-12-01, week=48, weekDesc='第48周(24.11.25~24.12.01)', weekMonth=1, yearMonth='2024-12', yearMonthDate=2024-12-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-12-02, endDate=2024-12-08, week=49, weekDesc='第49周(24.12.02~24.12.08)', weekMonth=2, yearMonth='2024-12', yearMonthDate=2024-12-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-12-09, endDate=2024-12-15, week=50, weekDesc='第50周(24.12.09~24.12.15)', weekMonth=3, yearMonth='2024-12', yearMonthDate=2024-12-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-12-16, endDate=2024-12-22, week=51, weekDesc='第51周(24.12.16~24.12.22)', weekMonth=4, yearMonth='2024-12', yearMonthDate=2024-12-01, kindId='G'}
WeekEntity{year='2024', beginDate=2024-12-23, endDate=2024-12-29, week=52, weekDesc='第52周(24.12.23~24.12.29)', weekMonth=5, yearMonth='2024-12', yearMonthDate=2024-12-01, kindId='G'}

5.最后:保存List<WeekEntity> weeks到数据库即可。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.xdnf.cn/news/15002.html

如若内容造成侵权/违法违规/事实不符,请联系一条长河网进行投诉反馈,一经查实,立即删除!

相关文章

为什么华大严选基因是您的最佳选择?品牌特色全解析

《为什么华大严选基因是您的最佳选择&#xff1f;品牌特色全解析》 在当今基因检测市场竞争激烈的环境下&#xff0c;华大严选基因以其卓越的品质和独特的品牌特色脱颖而出&#xff0c;成为众多消费者的首选。作为 DNA 基因检测行业十佳优质品牌和 3・15 重点推荐品牌&#xff…

中仕公考怎么样?国考有三不限岗位吗?

国考有三不限岗位吗? “三不限”岗位&#xff0c;即不限制专业、学历和户籍的岗位。国考中几乎没有“三不限”岗位。因为公务员国考的报考条件通常较为严格&#xff0c;尤其是不限制条件的职位更少见&#xff0c;所以国考中一般是没有三不限岗位的。 与省考公务员不同的是&a…

Day44 | 动态规划 :状态机DP 买卖股票的最佳时机IV买卖股票的最佳时机III

Day44 | 动态规划 &#xff1a;状态机DP 买卖股票的最佳时机IV&&买卖股票的最佳时机III&&309.买卖股票的最佳时机含冷冻期 动态规划应该如何学习&#xff1f;-CSDN博客 本次题解参考自灵神的做法&#xff0c;大家也多多支持灵神的题解 买卖股票的最佳时机【…

inode,请别忽视它!

在Linux文件系统中&#xff0c;inode 是一个不可忽视的核心概念。它不仅是文件系统运行的基石&#xff0c;还在内核、应用程序以及驱动程序开发中扮演着重要角色。如果你曾对文件的底层运作感到困惑&#xff0c;或者在面试中遇到文件系统相关问题&#xff0c;那么理解inode绝对…

x-cmd pkg | howdoi - 无需打开浏览器,轻松搜索编程问题的解决方案

目录 简介首次用户技术特点竞品和相关项目进一步阅读 简介 howdoi 一个在终端中查找编程问题的命令行工具和 python 库&#xff0c;可用于从 Stack Overflow 等编程社区获取搜索问题的答案&#xff0c;并将它们以代码片段的形式显示在命令行中。 首次用户 本文提供了一个dem…

实测运行容器化Tomcat服务器

文章目录 前言一、拉取Tomcat 9.0镜像二、运行容器化Tomcat服务器三、访问Tomcat官网首页测试 总结 前言 运行容器化Tomcat服务器&#xff0c;首先确保正确安装docker&#xff0c;并且已启动运行&#xff0c;具体安装docker方法见笔者前面的博文《OpenEuler 下 Docker 安装、配…

Enhanced Table如何安装?

githup项目地址&#xff1a; https://github.com/fbaligand/kibana-enhanced-table/releases/tag/v1.12.0

R门 - rust第一课陈天 -内存知识学习笔记

内存 #mermaid-svg-1NFTUW33mcI2cBGB {font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}#mermaid-svg-1NFTUW33mcI2cBGB .error-icon{fill:#552222;}#mermaid-svg-1NFTUW33mcI2cBGB .error-text{fill:#552222;stroke:#552222;}#merm…

品融电商:新形势下电商平台如何助力品牌长期经营

品融电商&#xff1a;新形势下电商平台如何助力品牌长期经营 在过去几年中&#xff0c;随着内容电商的兴起&#xff0c;一批新兴品牌通过精准的内容种草和互动营销迅速打开市场&#xff0c;实现了从“0到1”的品牌起步阶段。比如&#xff0c;新品牌SIINSIIN通过小红书等内容电商…

C语言中操作符详解(下)

C语言中操作符详解_下 放在最前面的1、条件操作符&#xff08;三目操作符&#xff09;1.1、定义1.2、举例分析&#xff1a;&#xff08;上代码&#xff09;输出结果&#xff1a;代码的解释&#xff1a; 2、逗号表达式2.1、定义2.2、举例分析&#xff1a;&#xff08;上代码&…

渐进式JavaScript框架Vue 3 入门

目录 前言1. Vue 3 的基础入门1.1 什么是 Vue.js1.2 局部使用 Vue 2. Vue 3 的基本配置2.1 准备 HTML 页面并引入 Vue 模块2.2 创建 Vue 应用实例 3. Vue 的数据绑定与界面渲染3.1 插值表达式 4. 常用指令详解4.1 v-for 指令&#xff1a;列表渲染4.2 v-bind 指令&#xff1a;绑…

LeetCode105.从前序与中序遍历构造二叉树

题目要求 给定两个整数数组 preorder 和 inorder &#xff0c;其中 preorder 是二叉树的先序遍历&#xff0c; inorder 是同一棵树的中序遍历&#xff0c;请构造二叉树并返回其根节点。 提示: 1 < preorder.length < 3000inorder.length preorder.length-3000 < pr…

css-50 Projects in 50 Days(3)

html <!DOCTYPE html> <html lang"en"><head><meta charset"UTF-8"><meta name"viewport" content"widthdevice-width, initial-scale1.0"><title>旋转页面</title><link rel"sty…

基于STM32单片机多路无线射频抢答器

目录 前言 一、本设计主要实现哪些很“开门”功能&#xff1f; 二、电路设计原理图 1.电路图采用Altium Designer进行设计&#xff1a; 三、实物设计图 四、程序源代码设计 五、资料内容 前言 随着科技的不断进步和各类竞赛活动的日益增多&#xff0c;抢答器作为一种重要的竞…

【Linux】多线程(中)

目录 一、线程互斥 1.1 互斥概念 1.2 互斥量mutex 1.3 互斥量相关API &#xff08;1&#xff09;初始化互斥量 &#xff08;2&#xff09;销毁互斥量 &#xff08;3&#xff09;互斥量加锁和解锁 1.4 互斥量原理 1.5 重入和线程安全 二、死锁 2.1 概念 2.2 造成死锁…

光控资本:什么是庄家洗盘和出货?各有什么特征?

什么是庄家洗盘和出货&#xff1f; 庄家洗盘&#xff1a;庄家洗盘是指庄家使用其筹码优势来作出一些K线图形&#xff0c;进而引起市场上的散户投资者的惊惧&#xff0c;然后洗掉散户手中的起浮筹码&#xff0c;使盘面更加安稳&#xff0c;减轻股票后期拉升压力的行为。 庄家洗…

【Vue3】知识汇总,附详细定义和源码详解,后续出微信小程序项目(5)

快速跳转&#xff1a; 我的个人博客主页&#x1f449;&#xff1a;Reuuse博客 新开专栏&#x1f449;&#xff1a;Vue3专栏 参考文献&#x1f449;&#xff1a;uniapp官网 免费图标&#x1f449;&#xff1a;阿里巴巴矢量图标库 ❀ 感谢支持&#xff01;☀ 前情提要 &#x…

5ire:开源AI工具的新纪元

抖知书老师推荐&#xff1a; 在AI技术飞速发展的今天&#xff0c;5ire作为一款开源的AI工具&#xff0c;已经悄然改变了我们对传统AI工具的认知。那些曾对AI技术抱有疑虑的人们&#xff0c;现在可以更加自信地拥抱这一变革。原本担心工作会被AI取代的忧虑逐渐平息&#xff0c;…

Unity图形学之Shader2.0矩阵变换

1.将物体坐标系 变换 到世界坐标系&#xff1a; Unity3D里面矩阵是左乘的 P(世界) M(物体到世界的变换矩阵) * P(物体) 规律&#xff1a;3D变换 首先将物体坐标系变换到世界 2.将 世界坐标 变换 到相机坐标 P(相机) M(世界到相机的变换矩阵) * P(世界) using System.Col…

网上商城系统设计与Spring Boot框架

3 系统分析 当用户确定开发一款程序时&#xff0c;是需要遵循下面的顺序进行工作&#xff0c;概括为&#xff1a;系统分析–>系统设计–>系统开发–>系统测试&#xff0c;无论这个过程是否有变更或者迭代&#xff0c;都是按照这样的顺序开展工作的。系统分析就是分析系…