mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-24 18:04:54 +08:00
fix code
This commit is contained in:
parent
69b3138b1b
commit
d41a22a458
@ -317,8 +317,8 @@ public class CIN {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 省份
|
||||
final String proCode = idCard.substring(0, 2);
|
||||
// 截取省份代码。新版外国人永久居留身份证以9开头,第二三位是受理地代码
|
||||
final String proCode = StrUtil.startWith(idCard, '9') ? idCard.substring(1, 3): idCard.substring(0, 2);
|
||||
if (null == CITY_CODES.get(proCode)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -164,4 +164,17 @@ public class IdcardUtilTest {
|
||||
flag = IdcardUtil.isValidTWCard(errTwCard2);
|
||||
Assertions.assertFalse(flag);
|
||||
}
|
||||
|
||||
@Test
|
||||
void foreignTest() {
|
||||
// 新版外国人永久居留身份证号码
|
||||
final String FOREIGN_ID_18 = "932682198501010017";
|
||||
Assertions.assertTrue(IdcardUtil.isValidCard(FOREIGN_ID_18));
|
||||
|
||||
final DateTime date = DateUtil.parse("2017-04-10");
|
||||
Assertions.assertEquals(IdcardUtil.getAge(FOREIGN_ID_18, date), 32);
|
||||
|
||||
// 新版外国人永久居留身份证
|
||||
Assertions.assertTrue(IdcardUtil.isValidCard18("932682198501010017"));
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,6 @@
|
||||
package org.dromara.hutool.cron.pattern.matcher;
|
||||
|
||||
import org.dromara.hutool.core.date.DateUtil;
|
||||
import org.dromara.hutool.core.lang.Console;
|
||||
import org.dromara.hutool.cron.pattern.Part;
|
||||
|
||||
import java.time.Year;
|
||||
@ -202,7 +201,7 @@ public class PatternMatcher {
|
||||
|
||||
if (i == Part.DAY_OF_MONTH.ordinal()) {
|
||||
final boolean isLeapYear = DateUtil.isLeapYear(newValues[Part.YEAR.ordinal()]);
|
||||
final int month = values[Part.MONTH.ordinal()];
|
||||
final int month = newValues[Part.MONTH.ordinal()];
|
||||
nextValue = ((DayOfMonthMatcher) matchers[i]).nextAfter(values[i], month, isLeapYear);
|
||||
} else {
|
||||
nextValue = matchers[i].nextAfter(values[i]);
|
||||
@ -235,7 +234,7 @@ public class PatternMatcher {
|
||||
|
||||
if (i == Part.DAY_OF_MONTH.ordinal()) {
|
||||
final boolean isLeapYear = DateUtil.isLeapYear(newValues[Part.YEAR.ordinal()]);
|
||||
final int month = values[Part.MONTH.ordinal()];
|
||||
final int month = newValues[Part.MONTH.ordinal()];
|
||||
nextValue = ((DayOfMonthMatcher) matchers[i]).nextAfter(values[i] + 1, month, isLeapYear);
|
||||
} else {
|
||||
nextValue = matchers[i].nextAfter(values[i] + 1);
|
||||
|
Loading…
Reference in New Issue
Block a user