计算干支纪月
()
| 302 | * 计算干支纪月 |
| 303 | */ |
| 304 | private void computeMonth() { |
| 305 | Solar start = null; |
| 306 | Solar end; |
| 307 | String ymd = solar.toYmd(); |
| 308 | String time = solar.toYmdHms(); |
| 309 | int size = JIE_QI_IN_USE.length; |
| 310 | |
| 311 | //序号:大雪以前-3,大雪到小寒之间-2,小寒到立春之间-1,立春之后0 |
| 312 | int index = -3; |
| 313 | for (int i = 0; i < size; i += 2) { |
| 314 | end = jieQi.get(JIE_QI_IN_USE[i]); |
| 315 | String symd = null == start ? ymd : start.toYmd(); |
| 316 | if (ymd.compareTo(symd) >= 0 && ymd.compareTo(end.toYmd()) < 0) { |
| 317 | break; |
| 318 | } |
| 319 | start = end; |
| 320 | index++; |
| 321 | } |
| 322 | |
| 323 | //干偏移值(以立春当天起算) |
| 324 | int offset = (((yearGanIndexByLiChun + (index < 0 ? 1 : 0)) % 5 + 1) * 2) % 10; |
| 325 | monthGanIndex = ((index < 0 ? index + 10 : index) + offset) % 10; |
| 326 | monthZhiIndex = ((index < 0 ? index + 12 : index) + LunarUtil.BASE_MONTH_ZHI_INDEX) % 12; |
| 327 | |
| 328 | start = null; |
| 329 | index = -3; |
| 330 | for (int i = 0; i < size; i += 2) { |
| 331 | end = jieQi.get(JIE_QI_IN_USE[i]); |
| 332 | String stime = null == start ? time : start.toYmdHms(); |
| 333 | if (time.compareTo(stime) >= 0 && time.compareTo(end.toYmdHms()) < 0) { |
| 334 | break; |
| 335 | } |
| 336 | start = end; |
| 337 | index++; |
| 338 | } |
| 339 | |
| 340 | //干偏移值(以立春交接时刻起算) |
| 341 | offset = (((yearGanIndexExact + (index < 0 ? 1 : 0)) % 5 + 1) * 2) % 10; |
| 342 | monthGanIndexExact = ((index < 0 ? index + 10 : index) + offset) % 10; |
| 343 | monthZhiIndexExact = ((index < 0 ? index + 12 : index) + LunarUtil.BASE_MONTH_ZHI_INDEX) % 12; |
| 344 | } |
| 345 | |
| 346 | /** |
| 347 | * 计算干支纪日 |