For more information on time, see Primitive Data Types.
The following are methods for Time.
public Time addHours(Integer additionalHours)
Type: Time
Time myTime = Time.newInstance(1, 2, 3, 4); Time expected = Time.newInstance(4, 2, 3, 4); System.assertEquals(expected, myTime.addHours(3));
public Time addMilliseconds(Integer additionalMilliseconds)
Type: Time
Time myTime = Time.newInstance(1, 2, 3, 0); Time expected = Time.newInstance(1, 2, 4, 400); System.assertEquals(expected, myTime.addMilliseconds(1400));
public Time addMinutes(Integer additionalMinutes)
Type: Time
Time myTime = Time.newInstance(18, 30, 2, 20); Integer myMinutes = myTime.minute(); myMinutes = myMinutes + 5; System.assertEquals(myMinutes, 35);
public Time addSeconds(Integer additionalSeconds)
Type: Time
Time myTime = Time.newInstance(1, 2, 55, 0); Time expected = Time.newInstance(1, 3, 5, 0); System.assertEquals(expected, myTime.addSeconds(10));
public Integer hour()
Type: Integer
Time myTime = Time.newInstance(18, 30, 2, 20); myTime = myTime.addHours(2); Integer myHour = myTime.hour(); System.assertEquals(myHour, 20);
public Integer millisecond()
Type: Integer
Time myTime = Time.newInstance(3, 14, 15, 926); System.assertEquals(926, myTime.millisecond());
public Integer minute()
Type: Integer
Time myTime = Time.newInstance(3, 14, 15, 926); System.assertEquals(14, myTime.minute());
public static Time newInstance(Integer hour, Integer minutes, Integer seconds, Integer milliseconds)
Type: Time
The following example creates a time of 18:30:2:20.
Time myTime = Time.newInstance(18, 30, 2, 20);
public Integer second()
Type: Integer
Time myTime = Time.newInstance(3, 14, 15, 926); System.assertEquals(15, myTime.second());