case 6:
solarday = getSolarTermNum("芒种");
if (solarday == d) ret = "芒种";
solarday = getSolarTermNum("夏至");
if (solarday == d) ret = "夏至";
break;
case 7:
solarday = getSolarTermNum("小暑");
if (solarday == d) ret = "小暑";
solarday = getSolarTermNum("大暑");
if (solarday == d) ret = "大暑";
break;
case 8:
solarday = getSolarTermNum("立秋");
if (solarday == d) ret = "立秋";
solarday = getSolarTermNum("处暑");
if (solarday == d) ret = "处暑";
break;
case 9:
solarday = getSolarTermNum("白露");
if (solarday == d) ret = "白露";
solarday = getSolarTermNum("秋分");
if (solarday == d) ret = "秋分";
break;
case 10:
solarday = getSolarTermNum("寒露");
if (solarday == d) ret = "寒露";
solarday = getSolarTermNum("霜降");
if (solarday == d) ret = "霜降";
break;
case 11:
solarday = getSolarTermNum("立冬");
if (solarday == d) ret = "立冬";
solarday = getSolarTermNum("小雪");
if (solarday == d) ret = "小雪";
break;
case 12:
solarday = getSolarTermNum("大雪");
if (solarday == d) ret = "大雪";
solarday = getSolarTermNum("冬至");
if (solarday == d) ret = "冬至";
break;
}
}
return ret;
}
public String toString() {
String year1 = "年";
String run1 = "闰";
String month1 = "月";
return cyclical() + animalsYear() + year1 + (leap ? run1 : "") + lunarMonthName[month - 1] + month1 + getChinaDayString(day);
}
public int getSolarTermNum(String name) {
double centuryValue = 0;
int centuryIndex = -1;
if (ye >= 1901 && ye <= 2000) {
centuryIndex = 0;
} else if (ye >= 2001 && ye <= 2100) {
centuryIndex = 1;
} else {
throw new RuntimeException("Not supported year:" + ye);
}
int i;
int ordinal = 0;
for (i = 0; i < SolarTerms.length; i++) {
if (SolarTerms[i].equals(name)) {
ordinal = i;
break;
}
}
centuryValue = CENTURY_ARRAY[centuryIndex][ordinal];
int dateNum = 0;
int y = ye % 100;
if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
if (name == "小寒" || name == "大寒" || name == "立春" || name == "雨水") {
y = y - 1;
}
}
dateNum = (int) (y * D + centuryValue) - (int) (y / 4);
dateNum += specialYearOffset(ye, name);
return dateNum;
}
public int specialYearOffset(int year, String name) {
int offset = 0;
offset += getOffset(DECREASE_OFFSETMAP, year, name, -1);
offset += getOffset(INCREASE_OFFSETMAP, year, name, 1);
return offset;
}
public int getOffset(Map map, int year, String name, int offset) {
int off = 0;
Integer[] years = map.get(name);
if (null != years) {
for (int i : years) {
if (i == year) {
off = offset;
break;
}
}
}
return off;
}
}