TelephoneNumberAdapter extends XmlAdapter<String, String> { @Override @Nullable public String marshal(@Nullable final String v) throws NumberParseException { if (v == null) { return null; } return format(v); }  @Override @Nullable String unmarshal(@Nullable final String v); @Override @Nullable String marshal(@Nullable final String v); @Nonnull static String format(@Nonnull final String value);  }
@Test public void testMarshal() throws NumberParseException { LOG.info("Test: testMarshal"); marshal("+31 (0)6-12345678", "+31612345678"); marshal("+31 20 1234567", "+31201234567"); marshal("+31 020-1234567", "+31201234567"); marshal("+31 (0)20 1234567", "+31201234567"); marshal("+31 020 123.45.67", "+31201234567"); marshal("+31 (0)20 123.45.67", "+31201234567"); marshal("+44 070 1234 5678", "+447012345678"); marshal("+44 (0)70 1234 5678", "+447012345678"); marshal("+44 20 1234 5678", "+442012345678"); marshal("+44 01204 12345", "+44120412345"); marshal("+44 016977 1234", "+44169771234"); marshal("+44 (0)169771234", "+44169771234"); marshal("+44 131 123 4567", "+441311234567"); marshal("+44 131 123 4567", "+441311234567"); marshal("+33 1 12345678", "+33112345678"); marshal("+33 6 12345678", "+33612345678"); marshal("+33 7 12345678", "+33712345678"); marshal("+1 (234) 235 5678", "+12342355678"); marshal("+12342355678", "+12342355678"); marshal("+27 021 1234567", "+27211234567"); marshal("+27(021)1234567", "+27211234567"); marshal("+55 2345 6789", "+5523456789"); marshal("+55 7890 7890", "+5578907890"); Assert.assertTrue(true); }