Class Time
A class for representing time as objects. Time is a complex data type representing the time of the day in hours, minutes, and seconds. The default value is now. ISO 8601 uses the 24-hour clock system. Format: hh:mm:ss
Examples
Time t;
print(t.toString());
Constructors
Time(Time)
Pass a value to copy into a new object.
Declaration
Time Time(Time value)
Examples
Time d;
Time t;
Time prev = Time(t);
printLine(prev.toString());
Parameters
Type | Name | Description |
Time | value | Time object. |
Type | Description |
Time |
Time(String)
Pass a String containing a timestamp on format HH:MM:SS. The constructor will parse the text and create a Time object.
Declaration
Time Time(String value)
Examples
String noon = "12:00:00";
Time lunch = Time(noon);
Time dailyMeeting = Time("08:00:00");
Parameters
Type | Name | Description |
String | value | A timestamp (HH:MM:SS). |
Type | Description |
Time |
Methods
toString()
Converts a Time value to its string representation.
One of the most frequently used methods, typically when you are going to output something.Declaration
String toString()
Examples
Time t;
String s = t.toString();
Returns
Type | Description |
String |
setHour(Integer)
Overwrites the current time and sets hours to the given number [0-23].
Declaration
Void setHour(Integer hour)
Examples
Time t;
t.setHour(14);
Parameters
Type | Name | Description |
Integer | hour | Number of hours, 0-23. |
Returns
Type | Description |
setMin(Integer)
Overwrites the current time and sets minutes to the given number [0-59].
Declaration
Void setMin(Integer min)
Examples
Time t;
t.setMin(37);
Parameters
Type | Name | Description |
Integer | min | Number of minutes, 0-59. |
Returns
Type | Description |
setSec(Integer)
Overwrites the current time and sets seconds to the given number [0-59].
Declaration
Void setSec(Integer sec)
Examples
Time t;
t.setSec(0);
Parameters
Type | Name | Description |
Integer | sec | Number of seconds, 0-59. |
Returns
Type | Description |
getHour()
Returns the hour portion of the time as an Integer.
Declaration
Integer getHour()
Examples
Time t;
print(t.getHour().toString());
Returns
Type | Description |
Integer |
getMin()
Returns the minutes portion of the time as an Integer.
Declaration
Integer getMin()
Examples
Time t;
print(t.getMin().toString());
Returns
Type | Description |
Integer |
getSec()
Returns the seconds portion of the time as an Integer.
Declaration
Integer getSec()
Examples
Time t;
print(t.getSec().toString());
Returns
Type | Description |
Integer |
isNull()
Returns true if it has no value and false if it does.
Declaration
Bool isNull()
Examples
Time t;
print(t.isNull().toString());
Returns
Type | Description |
Bool |