@Test public void usZipCodeTest() { assertTrue(CountryUtils.isUSZipCodeValid("94107")); assertTrue(CountryUtils.isUSZipCodeValid("94107-1234")); assertFalse(CountryUtils.isUSZipCodeValid("941071234")); assertFalse(CountryUtils.isUSZipCodeValid("9410a1234")); assertFalse(CountryUtils.isUSZipCodeValid("94107-")); assertFalse(CountryUtils.isUSZipCodeValid("9410&")); assertFalse(CountryUtils.isUSZipCodeValid("K1A 0B1")); assertFalse(CountryUtils.isUSZipCodeValid("")); }
static boolean isUSZipCodeValid(@NonNull String zipCode) { return Pattern.matches("^[0-9]{5}(?:-[0-9]{4})?$", zipCode); }
CountryUtils { static boolean isUSZipCodeValid(@NonNull String zipCode) { return Pattern.matches("^[0-9]{5}(?:-[0-9]{4})?$", zipCode); } }
CountryUtils { static boolean isUSZipCodeValid(@NonNull String zipCode) { return Pattern.matches("^[0-9]{5}(?:-[0-9]{4})?$", zipCode); }  }
CountryUtils { static boolean isUSZipCodeValid(@NonNull String zipCode) { return Pattern.matches("^[0-9]{5}(?:-[0-9]{4})?$", zipCode); }   }
CountryUtils { static boolean isUSZipCodeValid(@NonNull String zipCode) { return Pattern.matches("^[0-9]{5}(?:-[0-9]{4})?$", zipCode); }    }