static void testGetDatetimeValue() { JSONParse parser = new JSONParse("\"2011-03-22T13:01:23\""); System.assertEquals(Datetime.newInstanceGmt(2011, 3, 22, 13, 1, 23), parser.getDatetimeValue()); parser = new JSONParse("1538783039073"); System.assertEquals(Datetime.newInstanceGmt(2018, 10, 05, 23, 43, 59), parser.getDatetimeValue()); try { parser = new JSONParse("[1,2,3]"); parser.getDatetimeValue(); System.assert(false, "Node is not a valid Datetime, should have seen an exception about that."); } catch (JSONParse.InvalidConversionException e) { System.assertEquals("Only Long and String values can be converted to a Datetime: [ 1, 2, 3 ]", e.getMessage()); } }