public class Time
extends java.lang.Object
Object
Constructor and Description |
---|
Time()
Time no-argument constructor initializes each instance variable
to zero.
|
Time(int hour)
Time constructor
|
Time(int hour,
int minute)
Time constructor
|
Time(int hour,
int minute,
int second)
Time constructor
|
Time(Time time)
Time constructor
|
Modifier and Type | Method and Description |
---|---|
int |
getHour()
Gets the hour.
|
int |
getMinute()
Gets the minute.
|
int |
getSecond()
Gets the second.
|
void |
setHour(int hour)
Sets the hour.
|
void |
setMinute(int minute)
Sets the minute.
|
void |
setSecond(int second)
Sets the second.
|
void |
setTime(int hour,
int minute,
int second)
Set a new time value using universal time.
|
java.lang.String |
toString()
Convert to String in standard-time format
|
java.lang.String |
toUniversalString()
Convert to String in universal-time format
|
public Time()
java.lang.IllegalArgumentException
- In the case of an invalid timepublic Time(int hour)
hour
- the hourjava.lang.Exception
- In the case of an invalid timepublic Time(int hour, int minute)
hour
- the hourminute
- the minutejava.lang.IllegalArgumentException
- In the case of an invalid timepublic Time(int hour, int minute, int second)
hour
- the hourminute
- the minutesecond
- the secondjava.lang.IllegalArgumentException
- In the case of an invalid timepublic Time(Time time)
time
- A Time object with which to initializejava.lang.IllegalArgumentException
- In the case of an invalid timepublic void setTime(int hour, int minute, int second)
hour
- the hourminute
- the minutesecond
- the secondjava.lang.Exception
- In the case of an invalid timesetHour(int)
,
setMinute(int)
,
setSecond(int)
public void setHour(int hour)
hour
- the hourjava.lang.IllegalArgumentException
- In the case of an invalid hourpublic void setMinute(int minute)
minute
- the minutejava.lang.IllegalArgumentException
- In the case of an invalid minutepublic void setSecond(int second)
second
- the second.java.lang.Exception
- In the case of an invalid secondpublic int getHour()
integer
specifying the hour.public int getMinute()
integer
specifying the minute.public int getSecond()
integer
specifying the second.public java.lang.String toUniversalString()
String
representation
of the time in universal-time formatpublic java.lang.String toString()
toString
in class java.lang.Object
String
representation
of the time in standard-time format