public class Time extends Object
TimeSentence
.TimeSentence
,
Date
Constructor and Description |
---|
Time()
Creates a new instance of
Time using the current system
time. |
Time(int hour,
int min,
double sec)
Creates a new instance of Time with hours, minutes and seconds.
|
Time(int hour,
int min,
double sec,
int offsetHrs,
int offsetMin)
Creates a new instance of Time with time zone offsets.
|
Time(String time)
Creates a new instance of
Time based on given String. |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
int |
getHour()
Get the hour of day.
|
long |
getMilliseconds()
Get time as milliseconds since beginning of day.
|
int |
getMinutes()
Get the minute of hour.
|
int |
getOffsetHours()
Get time zone offset hours.
|
int |
getOffsetMinutes()
Get time zone offset minutes.
|
double |
getSeconds()
Get the second of minute.
|
int |
hashCode() |
void |
setHour(int hour)
Set the hour of day.
|
void |
setMinutes(int minutes)
Set the minute of hour.
|
void |
setOffsetHours(int hours)
Set time zone offset hours.
|
void |
setOffsetMinutes(int minutes)
Set time zone offset minutes.
|
void |
setSeconds(double seconds)
Set seconds of minute.
|
void |
setTime(Date d)
Set the time by
Date . |
Date |
toDate(Date d)
Convert to
Date . |
String |
toISO8601()
Returns the ISO 8601 representation of time (
hh:mm:ss+hh:mm ). |
String |
toString()
Returns the String representation of
Time . |
public Time()
Time
using the current system
time.public Time(String time)
Time
based on given String.
Assumes the hhmmss.sss
formatting used in NMEA sentences.time
- Timestamp Stringpublic Time(int hour, int min, double sec)
hour
- Hour of daymin
- Minute of hoursec
- Second of minutepublic Time(int hour, int min, double sec, int offsetHrs, int offsetMin)
hour
- Hour of daymin
- Minute of hoursec
- Second of minuteoffsetHrs
- Time zone offset hoursoffsetMin
- Time zone offset minutespublic int getHour()
public long getMilliseconds()
public int getMinutes()
public int getOffsetHours()
public int getOffsetMinutes()
public double getSeconds()
public void setHour(int hour)
hour
- the hour to setIllegalArgumentException
- If hour value out of bounds 0..23public void setMinutes(int minutes)
minutes
- the minute to setIllegalArgumentException
- If minutes value out of bounds 0..59public void setOffsetHours(int hours)
hours
- Offset to set (-13..13)IllegalArgumentException
- If offset out of bounds.public void setOffsetMinutes(int minutes)
minutes
- Offset to set (-59..59)IllegalArgumentException
- If offset out of bounds.public void setSeconds(double seconds)
seconds
- Seconds to setIllegalArgumentException
- If seconds out of bounds (
0 < seconds < 60
)public void setTime(Date d)
Date
. The date information of is
ignored, only hours, minutes and seconds are relevant. Notice also that
time zone offset is not affected by this method because
Date
does not contain zone offset.d
- Datepublic Date toDate(Date d)
Date
. Notice that time zone information is
lost in conversion as Date
does not contain time zone.d
- Date that defines year, month and day for time.public String toString()
Time
. Formats the time
in hhmmss.sss
format used in NMEA 0183 sentences. Seconds
are presented with three decimals regardless of precision returned by
getSeconds()
.public String toISO8601()
hh:mm:ss+hh:mm
).Copyright (C) 2010-2017 Java Marine API authors. All Rights Reserved.