Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.deitel
Class Time

    java.lang.Object
      com.deitel.Time

    public class Time

extends Object

This class maintains the time in 24-hour format.

Author:
  Deitel & Associates, Inc.
See Also:
  `Object`

Constructor Summary
`Time()` Time no-argument constructor initializes each instance variable to zero.
`Time(int h)` Time constructor
`Time(int h, int m)` Time constructor
`Time(int h, int m, int s)` Time constructor
`Time(Time time)` Time constructor

Method Summary
`int` | `getHour()` Gets the hour.
`int` | `getMinute()` Gets the minute.
`int` | `getSecond()` Gets the second.
`void` | `setHour(int h)` Sets the hour.
`void` | `setMinute(int m)` Sets the minute.
`void` | `setSecond(int s)` Sets the second.
`void` | `setTime(int h, int m, int s)` Set a new time value using universal time.
`String` | `toStandardString()` Convert to String in standard-time format
`String` | `toUniversalString()` Convert to String in universal-time format

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Time

    public Time()
         throws Exception

  Time no-argument constructor initializes each instance variable to zero. This ensures that Time objects start in a consistent state. @throws Exception In the case of an invalid time

  Throws:
    `Exception`

### Time

    public Time(int h)
         throws Exception

  Time constructor

  Parameters:
    `h` - the hour
  Throws:
    `Exception` - In the case of an invalid time

### Time

    public Time(int h,
                int m)
         throws Exception

  Time constructor

  Parameters:
    `h` - the hour
    `m` - the minute
  Throws:
    `Exception` - In the case of an invalid time

### Time

    public Time(int h,
                int m,
                int s)
         throws Exception

  Time constructor

  Parameters:
    `h` - the hour
    `m` - the minute
    `s` - the second
  Throws:
    `Exception` - In the case of an invalid time

### Time

    public Time(Time time)
         throws Exception

  Time constructor

  Parameters:
    `time` - A Time object with which to initialize
  Throws:
    `Exception` - In the case of an invalid time

Method Detail

### setTime

    public void setTime(int h,
                        int m,
                        int s)
                 throws Exception

  Set a new time value using universal time. Perform validity checks on the data. Set invalid values to zero.

  Parameters:
    `h` - the hour
    `m` - the minute
    `s` - the second
  Throws:
    `Exception` - In the case of an invalid time
  See Also:
    `com.deitel.jhtp6.appenH.Time#setHour`, `setMinute(int)`, `setSecond(int)`

### setHour

    public void setHour(int h)
                 throws Exception

  Sets the hour.

  Parameters:
    `h` - the hour
  Throws:
    `Exception` - In the case of an invalid time

### setMinute

    public void setMinute(int m)
                   throws Exception

  Sets the minute.

  Parameters:
    `m` - the minute
  Throws:
    `Exception` - In the case of an invalid time

### setSecond

    public void setSecond(int s)
                   throws Exception

  Sets the second.

  Parameters:
    `s` - the second.
  Throws:
    `Exception` - In the case of an invalid time

### getHour

    public int getHour()

  Gets the hour.

  Returns:
    an `integer` specifying the hour.

### getMinute

    public int getMinute()

  Gets the minute.

  Returns:
    an `integer` specifying the minute.

### getSecond

    public int getSecond()

  Gets the second.

  Returns:
    an `integer` specifying the second.

### toUniversalString

    public String toUniversalString()

  Convert to String in universal-time format

  Returns:
    a `String` representation of the time in universal-time format

### toStandardString

    public String toStandardString()

  Convert to String in standard-time format

  Returns:
    a `String` representation of the time in standard-time format

Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD