类 Time
java.lang.Object
net.sf.marineapi.nmea.util.Time
Represents a time of day in 24-hour clock, i.e. the UTC time used as default
in NMEA 0183. Transmitted by
TimeSentence.- 作者:
- Kimmo Tuukkanen
- 另请参阅:
-
构造器概要
构造器构造器说明Time()Creates a new instance ofTimeusing 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.Creates a new instance ofTimebased on given String. -
方法概要
修饰符和类型方法说明booleanintgetHour()Get the hour of day.longGet time as milliseconds since beginning of day.intGet the minute of hour.intGet time zone offset hours.intGet time zone offset minutes.doubleGet the second of minute.inthashCode()voidsetHour(int hour) Set the hour of day.voidsetMinutes(int minutes) Set the minute of hour.voidsetOffsetHours(int hours) Set time zone offset hours.voidsetOffsetMinutes(int minutes) Set time zone offset minutes.voidsetSeconds(double seconds) Set seconds of minute.voidSet the time byDate.Convert toDate.Returns the ISO 8601 representation of time (hh:mm:ss+hh:mm).toString()Returns the String representation ofTime.
-
构造器详细资料
-
Time
public Time()Creates a new instance ofTimeusing the current system time. -
Time
Creates a new instance ofTimebased on given String. Assumes thehhmmss.sssformatting used in NMEA sentences.- 参数:
time- Timestamp String
-
Time
public Time(int hour, int min, double sec) Creates a new instance of Time with hours, minutes and seconds.- 参数:
hour- Hour of daymin- Minute of hoursec- Second of minute
-
Time
public Time(int hour, int min, double sec, int offsetHrs, int offsetMin) Creates a new instance of Time with time zone offsets.- 参数:
hour- Hour of daymin- Minute of hoursec- Second of minuteoffsetHrs- Time zone offset hoursoffsetMin- Time zone offset minutes
-
-
方法详细资料
-
equals
-
getHour
public int getHour()Get the hour of day.- 返回:
- the hour
-
getMilliseconds
public long getMilliseconds()Get time as milliseconds since beginning of day.- 返回:
- Milliseconds
-
getMinutes
public int getMinutes()Get the minute of hour.- 返回:
- the minute
-
getOffsetHours
public int getOffsetHours()Get time zone offset hours. Defaults to 0 (UTC).- 返回:
- Offset hours as int.
-
getOffsetMinutes
public int getOffsetMinutes()Get time zone offset minutes. Defaults to 0 (UTC).- 返回:
- Offset minutes as int.
-
getSeconds
public double getSeconds()Get the second of minute.- 返回:
- the second
-
hashCode
public int hashCode() -
setHour
public void setHour(int hour) Set the hour of day.- 参数:
hour- the hour to set- 抛出:
IllegalArgumentException- If hour value out of bounds 0..23
-
setMinutes
public void setMinutes(int minutes) Set the minute of hour.- 参数:
minutes- the minute to set- 抛出:
IllegalArgumentException- If minutes value out of bounds 0..59
-
setOffsetHours
public void setOffsetHours(int hours) Set time zone offset hours.- 参数:
hours- Offset to set (-13..13)- 抛出:
IllegalArgumentException- If offset out of bounds.
-
setOffsetMinutes
public void setOffsetMinutes(int minutes) Set time zone offset minutes.- 参数:
minutes- Offset to set (-59..59)- 抛出:
IllegalArgumentException- If offset out of bounds.
-
setSeconds
public void setSeconds(double seconds) Set seconds of minute.- 参数:
seconds- Seconds to set- 抛出:
IllegalArgumentException- If seconds out of bounds (0 < seconds < 60)
-
setTime
Set the time byDate. 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 becauseDatedoes not contain zone offset.- 参数:
d- Date
-
toDate
Convert toDate. Notice that time zone information is lost in conversion asDatedoes not contain time zone.- 参数:
d- Date that defines year, month and day for time.- 返回:
- A Date that is combination of specified Date and Time
-
toString
Returns the String representation ofTime. Formats the time inhhmmss.sssformat used in NMEA 0183 sentences. Seconds are presented with three decimals regardless of precision returned bygetSeconds(). -
toISO8601
Returns the ISO 8601 representation of time (hh:mm:ss+hh:mm).- 返回:
- ISO 8601 formatted time String.
-