@Test public void shouldConvertCalendarto8601() throws ConverterException { Calendar cal = getExpectedCalendar(); String isoStr = calToiso(cal); assertTrue(expectedIso.equals(isoStr)); assertFalse(isoStr.equals(wrongDate)); }
public static String calToiso(Calendar cal) throws ConverterException { String out; String msg; try { ZonedDateTime dateTime =ZonedDateTime.ofInstant(cal.toInstant(),ZoneOffset.UTC); DateTimeFormatter dtf = DateTimeFormatter.ISO_INSTANT; out = dtf.format(dateTime.withNano(0)); } catch (Exception ex) { throw new ConverterException(ex); } return out; }
DateTimeConverters { public static String calToiso(Calendar cal) throws ConverterException { String out; String msg; try { ZonedDateTime dateTime =ZonedDateTime.ofInstant(cal.toInstant(),ZoneOffset.UTC); DateTimeFormatter dtf = DateTimeFormatter.ISO_INSTANT; out = dtf.format(dateTime.withNano(0)); } catch (Exception ex) { throw new ConverterException(ex); } return out; } }
DateTimeConverters { public static String calToiso(Calendar cal) throws ConverterException { String out; String msg; try { ZonedDateTime dateTime =ZonedDateTime.ofInstant(cal.toInstant(),ZoneOffset.UTC); DateTimeFormatter dtf = DateTimeFormatter.ISO_INSTANT; out = dtf.format(dateTime.withNano(0)); } catch (Exception ex) { throw new ConverterException(ex); } return out; }  }
DateTimeConverters { public static String calToiso(Calendar cal) throws ConverterException { String out; String msg; try { ZonedDateTime dateTime =ZonedDateTime.ofInstant(cal.toInstant(),ZoneOffset.UTC); DateTimeFormatter dtf = DateTimeFormatter.ISO_INSTANT; out = dtf.format(dateTime.withNano(0)); } catch (Exception ex) { throw new ConverterException(ex); } return out; }  static Calendar isoTocalNoExc(String isoStr); static Calendar isoTocal(String isoStr); static String calToiso(Calendar cal); static String calToisoNoExc(Calendar cal); static void main(String[] ags); }
DateTimeConverters { public static String calToiso(Calendar cal) throws ConverterException { String out; String msg; try { ZonedDateTime dateTime =ZonedDateTime.ofInstant(cal.toInstant(),ZoneOffset.UTC); DateTimeFormatter dtf = DateTimeFormatter.ISO_INSTANT; out = dtf.format(dateTime.withNano(0)); } catch (Exception ex) { throw new ConverterException(ex); } return out; }  static Calendar isoTocalNoExc(String isoStr); static Calendar isoTocal(String isoStr); static String calToiso(Calendar cal); static String calToisoNoExc(Calendar cal); static void main(String[] ags); static final String defaultMinutes; }