Code example for Time

Methods: setTime, toString

0
 
    public void testSetTime() { 
        // Ensure that the timezone is set to GMT 
        TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
 
        Time theTime = new Time(TIME_TEST1);
        assertEquals(STRING_TEST1, theTime.toString());
 
        theTime.setTime(TIME_TEST2);
        assertEquals(STRING_TEST2, theTime.toString());
    } // end method testSetTime() 
 
    @SuppressWarnings("deprecation") 
    public void testSetDate() { 
        Time theTime = new Time(TIME_TEST1);
 
        try { 
            theTime.setDate(10);
            fail("Should throw IllegalArgumentException.");
        } catch (IllegalArgumentException e) {
            // expected