ISODate implements Cloneable, Comparable<ISODate>, Serializable, XmlEmbeddable { public static String parseISODateTime(final String stringToParse) { String newDateTime = parseISODateTimes(stringToParse, null); if (newDateTime.equals(DEFAULT_DATE_TIME)) { return null; } else { return newDateTime; } } ISODate();  ISODate(final long time, final boolean shortDate);  ISODate(final long time);  ISODate(@Nonnull final String isoDate); static String parseISODateTime(final String stringToParse); static String parseISODateTimes(String input1, String input2); static DateTime parseBasicOrFullDateTime(String input1); ISODate clone(); long timeDifferenceInSeconds(ISODate date); @Transient String getDateAsString(); String toString(); Date toDate(); @Transient long getTimeInSeconds(); @XmlValue String getDateAndTime(); void setDateAndTime(String isoDate); @Transient boolean isDateOnly(); @Transient boolean isDateYearOnly(); @Transient boolean isDateYearMonthOnly(); @Transient int getYears(); @Transient int getDays(); @Transient int getMonths(); @Transient int getHours(); @Transient int getMinutes(); @Transient int getSeconds(); @Override int hashCode(); @Override boolean equals(Object obj); @Transient String getTimeAsString(); @Override int compareTo(ISODate o); @Override void addToXml(Element element);  }
@Test public void testParseISODateTime() throws Exception { String jodaISODate = ISODate .parseISODateTime("2010-10-10T00:00:00+02:00"); assertTrue(jodaISODate.equals("2010-10-09T22:00:00.000Z")); jodaISODate = ISODate .parseISODateTime("2010-10-10T00:00:00.000+02:00"); assertTrue(jodaISODate.equals("2010-10-09T22:00:00.000Z")); jodaISODate = ISODate.parseISODateTime("2010-10-10T00:00:00Z"); assertTrue(jodaISODate.equals("2010-10-10T00:00:00.000Z")); jodaISODate = ISODate.parseISODateTime("2010-10-10T00:00:00.000Z"); assertTrue(jodaISODate.equals("2010-10-10T00:00:00.000Z")); }
@Test public void testParseYearMonthDateTime() throws Exception { for (int i = 0; i < 10; i++) { String year = "20" + getRandom(1, 0) + getRandom(9, 0); String month = "0" + getRandom(9, 1); String hour = getRandom(1, 0) + "" + getRandom(9, 0); String minutes = getRandom(5, 1) + "" + getRandom(9, 0); String tmp = year + "-" + month + "-" + hour + ":" + minutes + "Z"; String jodaISODate = ISODate.parseISODateTime(tmp); assertEquals(jodaISODate, year + "-" + month + "-01T" + hour + ":" + minutes + ":00.000Z"); year = "20" + getRandom(1, 0) + getRandom(9, 0); month = "0" + getRandom(9, 1); tmp = year + "-" + month; jodaISODate = ISODate.parseISODateTime(tmp); assertEquals(jodaISODate, tmp + "-01T00:00:00.000Z"); } }
@Test public void testParseYearDateTime() throws Exception { for (int i = 0; i < 10; i++) { String year = "20" + getRandom(1, 0) + getRandom(9, 0); String hour = getRandom(1, 0) + "" + getRandom(9, 0); String minutes = getRandom(5, 1) + "" + getRandom(9, 0); String jodaISODate = ISODate.parseISODateTime(year + "-" + hour + ":" + minutes + "Z"); assertEquals(jodaISODate, year + "-01-01T" + hour + ":" + minutes + ":00.000Z"); year = "20" + getRandom(1, 0) + getRandom(9, 0); jodaISODate = ISODate.parseISODateTime(year); assertEquals(jodaISODate, year + "-01-01T00:00:00.000Z"); } }