### Question:
XmppDateTime { public static Date parseXEP0082Date(String dateString) throws ParseException { for (PatternCouplings coupling : couplings) { Matcher matcher = coupling.pattern.matcher(dateString); if (matcher.matches()) { return coupling.formatter.parse(dateString); } } return dateTimeNoMillisFormatter.parse(dateString); }  static Date parseXEP0082Date(String dateString); static Date parseDate(String dateString); static String formatXEP0082Date(Date date); static String convertXep82TimezoneToRfc822(String dateString); static String convertRfc822TimezoneToXep82(String dateString); static String asString(TimeZone timeZone);  }### Answer:
@Test public void parseXep0082Date() throws Exception { Date date = XmppDateTime.parseDate("1971-07-21"); Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.setTimeZone(TimeZone.getTimeZone("GMT")); assertEquals(1971, cal.get(Calendar.YEAR)); assertEquals(6, cal.get(Calendar.MONTH)); assertEquals(21, cal.get(Calendar.DAY_OF_MONTH)); }
@Test(expected = ParseException.class) public void parseXep0082MissingTzd() throws ParseException { XmppDateTime.parseXEP0082Date("2017-07-11T18:31:34"); }
@Test public void testLeapSeconds() throws ParseException { Date date = XmppDateTime.parseXEP0082Date("2015-07-31T23:59:60Z"); Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.setTimeZone(TimeZone.getTimeZone("GMT")); assertEquals(0, cal.get(Calendar.SECOND)); }
@Test public void testLeapSeconds3() throws ParseException { Date date = XmppDateTime.parseXEP0082Date("2015-05-31T23:59:63Z"); Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.setTimeZone(TimeZone.getTimeZone("GMT")); assertEquals(3, cal.get(Calendar.SECOND)); }