1
0
mirror of synced 2026-04-15 04:48:40 +08:00

Merge branch 'v1.1.0-SNAPSHOT'

This commit is contained in:
6tail
2020-11-25 22:43:54 +08:00
2 changed files with 83 additions and 13 deletions

File diff suppressed because one or more lines are too long

View File

@@ -1,11 +1,81 @@
package test; package test;
import com.nlf.calendar.Solar;
import com.nlf.calendar.util.HolidayUtil; import com.nlf.calendar.util.HolidayUtil;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
public class HolidayTest { public class HolidayTest {
@Test
public void test2021() {
Map<String, String> holidays = new HashMap<String, String>() {
private static final long serialVersionUID = 1L;
{
put("2021-01-01", "2021-01-01 元旦节 2021-01-01");
put("2021-01-02", "2021-01-02 元旦节 2021-01-01");
put("2021-01-03", "2021-01-03 元旦节 2021-01-01");
put("2021-02-11", "2021-02-11 春节 2021-02-12");
put("2021-02-12", "2021-02-12 春节 2021-02-12");
put("2021-02-13", "2021-02-13 春节 2021-02-12");
put("2021-02-14", "2021-02-14 春节 2021-02-12");
put("2021-02-15", "2021-02-15 春节 2021-02-12");
put("2021-02-16", "2021-02-16 春节 2021-02-12");
put("2021-02-17", "2021-02-17 春节 2021-02-12");
put("2021-02-07", "2021-02-07 春节调休 2021-02-12");
put("2021-02-20", "2021-02-20 春节调休 2021-02-12");
put("2021-04-03", "2021-04-03 清明节 2021-04-04");
put("2021-04-04", "2021-04-04 清明节 2021-04-04");
put("2021-04-05", "2021-04-05 清明节 2021-04-04");
put("2021-05-01", "2021-05-01 劳动节 2021-05-01");
put("2021-05-02", "2021-05-02 劳动节 2021-05-01");
put("2021-05-03", "2021-05-03 劳动节 2021-05-01");
put("2021-05-04", "2021-05-04 劳动节 2021-05-01");
put("2021-05-05", "2021-05-05 劳动节 2021-05-01");
put("2021-04-25", "2021-04-25 劳动节调休 2021-05-01");
put("2021-05-08", "2021-05-08 劳动节调休 2021-05-01");
put("2021-06-12", "2021-06-12 端午节 2021-06-14");
put("2021-06-13", "2021-06-13 端午节 2021-06-14");
put("2021-06-14", "2021-06-14 端午节 2021-06-14");
put("2021-09-19", "2021-09-19 中秋节 2021-09-21");
put("2021-09-20", "2021-09-20 中秋节 2021-09-21");
put("2021-09-21", "2021-09-21 中秋节 2021-09-21");
put("2021-09-18", "2021-09-18 中秋节调休 2021-09-21");
put("2021-10-01", "2021-10-01 国庆节 2021-10-01");
put("2021-10-02", "2021-10-02 国庆节 2021-10-01");
put("2021-10-03", "2021-10-03 国庆节 2021-10-01");
put("2021-10-04", "2021-10-04 国庆节 2021-10-01");
put("2021-10-05", "2021-10-05 国庆节 2021-10-01");
put("2021-10-06", "2021-10-06 国庆节 2021-10-01");
put("2021-10-07", "2021-10-07 国庆节 2021-10-01");
put("2021-09-26", "2021-09-26 国庆节调休 2021-10-01");
put("2021-10-09", "2021-10-09 国庆节调休 2021-10-01");
}
};
Solar solar = Solar.fromYmd(2021, 1, 1);
while (solar.toYmd().compareTo("2022-01-01") < 0) {
String ymd = solar.toYmd();
String holiday = holidays.get(ymd);
Assert.assertEquals(ymd, holiday + "", HolidayUtil.getHoliday(ymd) + "");
solar = solar.next(1);
}
}
@Test @Test
public void test() { public void test() {
Assert.assertEquals("2020-01-01 元旦节 2020-01-01", HolidayUtil.getHoliday("2020-01-01") + ""); Assert.assertEquals("2020-01-01 元旦节 2020-01-01", HolidayUtil.getHoliday("2020-01-01") + "");