Code example for DateFormat

Methods: parse

0
    public void testInterval() throws ParseException { 
        TimeKvpParser timeKvpParser = new TimeKvpParser("TIME");
        List l = new ArrayList((Collection) timeKvpParser.parse(PERIOD));
        // Verify that the list contains at least one element. 
        assertFalse(l.isEmpty());
        assertEquals(format.parse("2007-01-01T12Z"), l.get(0));
        assertEquals(format.parse("2007-01-03T00Z"), l.get(1));
        assertEquals(format.parse("2007-01-04T12Z"), l.get(2));
        assertEquals(format.parse("2007-01-06T00Z"), l.get(3));
        assertEquals(format.parse("2007-01-07T12Z"), l.get(4));
        assertEquals(format.parse("2007-01-09T00Z"), l.get(5));
        assertEquals(format.parse("2007-01-10T12Z"), l.get(6));
        assertEquals(format.parse("2007-01-12T00Z"), l.get(7));
         
        l = new ArrayList((Collection) timeKvpParser.parse("2007-01-01T12Z/2007-01-31T12Z/PT01S"));
        // Verify that the list contains at least one element. 
        assertFalse(l.isEmpty());
        assertTrue(l.size()==100);
        assertEquals(format.parse("2007-01-01T12Z"), l.get(0));
    } 
     
    public void testContinuousInterval() throws ParseException { 
        TimeKvpParser timeKvpParser = new TimeKvpParser("TIME");
        List l = new ArrayList((Collection)  timeKvpParser.parse(CONTINUOUS_PERIOD));