Show / Hide Table of Contents

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

Syntax
Examples
Time t;
print(t.toString());

Constructors

Time()

Default constructor.

Declaration
Time Time()
Returns
Type Description
Time
Examples
Time t;
print(t.toString());

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)
Parameters
Type Name Description
String value

A timestamp (HH:MM:SS).

Returns
Type Description
Time
Examples
String noon = "12:00:00";
Time lunch = Time(noon);
Time dailyMeeting = Time("08:00:00");

Time(Time)

Pass a value to copy into a new object.

Declaration
Time Time(Time value)
Parameters
Type Name Description
Time value

Time object.

Returns
Type Description
Time
Examples
Time d;
Time t;
Time prev = Time(t);
printLine(prev.toString());

Methods

getHour()

Returns the hour portion of the time as an Integer.

Declaration
Integer getHour()
Returns
Type Description
Integer
Examples
Time t;
print(t.getHour().toString());

getMin()

Returns the minutes portion of the time as an Integer.

Declaration
Integer getMin()
Returns
Type Description
Integer
Examples
Time t;
print(t.getMin().toString());

getSec()

Returns the seconds portion of the time as an Integer.

Declaration
Integer getSec()
Returns
Type Description
Integer
Examples
Time t;
print(t.getSec().toString());

isNull()

Returns true if it has no value and false if it does.

Declaration
Bool isNull()
Returns
Type Description
Bool
Remarks

A NULL/NUL/NIL Time is different from zero, in that it is conceptually without a value.

Examples
Time t;
print(t.isNull().toString());

setHour(Integer)

Overwrites the current time and sets hours to the given number [0-23].

Declaration
Void setHour(Integer hour)
Parameters
Type Name Description
Integer hour

Number of hours, 0-23.

Returns
Type Description
Examples
Time t;
t.setHour(14);

setMin(Integer)

Overwrites the current time and sets minutes to the given number [0-59].

Declaration
Void setMin(Integer min)
Parameters
Type Name Description
Integer min

Number of minutes, 0-59.

Returns
Type Description
Examples
Time t;
t.setMin(37);

setSec(Integer)

Overwrites the current time and sets seconds to the given number [0-59].

Declaration
Void setSec(Integer sec)
Parameters
Type Name Description
Integer sec

Number of seconds, 0-59.

Returns
Type Description
Examples
Time t;
t.setSec(0);

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()
Returns
Type Description
String
Examples
Time t;
String s = t.toString();
In This Article
© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top