예제 #1
0
        static void testGetDateValue()
        {
            JSONParse parser = new JSONParse("\"2011-03-22\"");

            System.assertEquals(Date.newInstance(2011, 3, 22), parser.getDateValue());
            parser = new JSONParse("1538783039073");
            System.assertEquals(Date.newInstance(2018, 10, 05), parser.getDateValue());
            try
            {
                parser = new JSONParse("[1,2,3]");
                parser.getDateValue();
                System.assert(false, "Node is not a valid Date, should have seen an exception about that.");
            }
            catch (JSONParse.InvalidConversionException e)
            {
                System.assertEquals("Only Long and String values can be converted to a Date: [ 1, 2, 3 ]", e.getMessage());
            }
        }