/**
* 解决千年虫问题,通过一码 Y 获取 YYYY,10年内的 DC
* 另外加未来日期的检查
*
* @param y
* @return
*/
public static int getYYYYFromY(int y) {
if (!(y < 10 && y >= 0)) {
throw new RuntimeException("参数 y 不合法!");
}
Integer thisYear = new JDateTime().getYear();
Integer thisYearLastChar = thisYear % 10;
if (y > thisYearLastChar) {
return (thisYear / 10 - 1) * 10 + y;
} else {
return thisYear - thisYearLastChar + y;
}
}