1.引入pom依赖
<!-- https://mvnrepository.com/artifact/com.googlecode.libphonenumber/libphonenumber -->
<dependency>
<groupId>com.googlecode.libphonenumber</groupId>
<artifactId>libphonenumber</artifactId>
<version>8.9.16</version>
</dependency>
2.测试用例
PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance();
try {
Phonenumber.PhoneNumber swissNumberProto = phoneUtil.parse("+8613266895464", "");
System.out.println(swissNumberProto.getCountryCode()+"phone"+swissNumberProto.getNationalNumber());
} catch (NumberParseException e) {
log.error("NumberParseException was thrown: " + e.toString());
}