No Results
Search Tips:
- Please consider misspellings
- Try different search keywords
Newer Version Available
Time Class
Contains methods for the Time primitive data type.
Namespace
Usage
For more information on time, see Primitive Data Types.
Time Methods
The following are methods for Time.
addMinutes(Integer)
Adds the specified number of minutes to a Time.
Signature
public Time addMinutes(Integer addlMinutes)
Parameters
- addlMinutes
- Type: Integer
Return Value
Type: Time
Example
1Time myTime =
2Time.newInstance(18, 30, 2, 20);
3
4Integer myMinutes = myTime.minute();
5myMinutes = myMinutes + 5;
6
7System.assertEquals(myMinutes, 35);hour()
Returns the hour component of a Time.
Signature
public Integer hour()
Return Value
Type: Integer
Example
1Time myTime =
2Time.newInstance(18, 30, 2, 20);
3
4myTime = myTime.addHours(2);
5
6Integer myHour = myTime.hour();
7System.assertEquals(myHour, 20);millisecond()
Returns the millisecond component of a Time.
Signature
public Integer millisecond()
Return Value
Type: Integer
minute()
Returns the minute component of a Time.
Signature
public Integer minute()
Return Value
Type: Integer
newInstance(Integer, Integer, Integer, Integer)
Constructs a Time from Integer representations of the specified
hour, minutes, seconds, and milliseconds.
Signature
public static Time newInstance(Integer hour, Integer minutes, Integer seconds, Integer milliseconds)
Parameters
Return Value
Type: Time
Example
The following example creates a time of 18:30:2:20.
1Time myTime =
2Time.newInstance(18, 30, 2, 20);second()
Returns the second component of a Time.
Signature
public Integer second()
Return Value
Type: Integer