DateAndTime { public static DateAndTime parseRfc3339String(String rfc3339String) { try { return new DateAndTime(rfc3339String); } catch (NumberFormatException e) { throw new IllegalArgumentException( "DateAndTime string is not valid RFC3339: " + rfc3339String, e); } } private  DateAndTime(String rfc3339String); String toRfc3339String(); static DateAndTime parseRfc3339String(String rfc3339String); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString();  }
@Test public void testInvalidRfc3339() { try { DateAndTime.parseRfc3339String("1937-01"); fail("Parsing string should have failed, it's not valid RFC3339"); } catch (IllegalArgumentException e) { } }