类 Date

java.lang.Object
net.sf.marineapi.nmea.util.Date

public class Date extends Object
Represents a calendar date (day-month-year) transmitted in sentences that implement DateSentence.
作者:
Kimmo Tuukkanen
另请参阅:
  • 字段概要

    字段
    修饰符和类型
    字段
    说明
    static final int
    A pivot value that is used to determine century for two-digit year values.
  • 构造器概要

    构造器
    构造器
    说明
    Creates a new instance of Date using the current date.
    Date(int year, int month, int day)
    Constructor with date values.
    Date(String date)
    Creates a new instance of Date, assumes the default NMEA 0183 date formatting, ddmmyy or ddmmyyyy.
  • 方法概要

    修饰符和类型
    方法
    说明
    boolean
     
    int
    Get day of month.
    int
    Get month, valid values are 1-12 where 1 denotes January, 2 denotes February etc.
    int
    Get year.
    int
     
    void
    setDay(int day)
    Set day of month.
    void
    setMonth(int month)
    Get month, valid values are 1-12 where 1 denotes January, 2 denotes February etc.
    void
    setYear(int year)
    Set year.
    Converts to Date, time of day set to 00:00:00.000.
    Returns the date in ISO 8601 format (yyyy-mm-dd).
    Returns a timestamp in ISO 8601 format (yyyy-mm-ddThh:mm:ss+hh:mm).
    Returns the String representation of Date.

    从类继承的方法 java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • 字段详细资料

    • PIVOT_YEAR

      public static final int PIVOT_YEAR
      A pivot value that is used to determine century for two-digit year values. Two-digit values lower than or equal to pivot are assigned to 21th century, while greater values are assigned to 20th century.
      另请参阅:
  • 构造器详细资料

    • Date

      public Date()
      Creates a new instance of Date using the current date.
    • Date

      public Date(String date)
      Creates a new instance of Date, assumes the default NMEA 0183 date formatting, ddmmyy or ddmmyyyy.
      参数:
      date - Date String to parse.
    • Date

      public Date(int year, int month, int day)
      Constructor with date values.
      参数:
      year - Year, two or four digit value [0..99] or [1000..9999]
      month - Month [1..12]
      day - Day [1..31]
      抛出:
      IllegalArgumentException - If any of the parameter is out of bounds.
  • 方法详细资料

    • equals

      public boolean equals(Object obj)
      覆盖:
      equals 在类中 Object
    • getDay

      public int getDay()
      Get day of month.
      返回:
      the day
    • getMonth

      public int getMonth()
      Get month, valid values are 1-12 where 1 denotes January, 2 denotes February etc.
      返回:
      the month
    • getYear

      public int getYear()
      Get year. The date fields in NMEA 0183 may present year by using either two or four digits. In case of only two digits, the century is determined by comparing the value against PIVOT_YEAR. Values lower than or equal to pivot are added to 2000, while values greater than pivot are added to 1900.
      返回:
      The four-digit year
      另请参阅:
    • hashCode

      public int hashCode()
      覆盖:
      hashCode 在类中 Object
    • setDay

      public void setDay(int day)
      Set day of month.
      参数:
      day - the day to set
    • setMonth

      public void setMonth(int month)
      Get month, valid values are 1-12 where 1 denotes January, 2 denotes February etc.
      参数:
      month - the month to set
      抛出:
      IllegalArgumentException - If specified value is out of bounds [1..12]
    • setYear

      public void setYear(int year)
      Set year. The date fields in NMEA 0183 may present year by using either two or four digits. In case of only two digits, the century is determined by comparing the value against PIVOT_YEAR. Values lower than or equal to pivot are added to 2000, while values greater than pivot are added to 1900.
      参数:
      year - Year to set, two or four digit value.
      抛出:
      IllegalArgumentException - If specified value is negative or three-digit value.
      另请参阅:
    • toString

      public String toString()
      Returns the String representation of Date. Formats the date in ddmmyy format used in NMEA 0183 sentences.
      覆盖:
      toString 在类中 Object
    • toISO8601

      public String toISO8601()
      Returns the date in ISO 8601 format (yyyy-mm-dd).
      返回:
      Formatted date String
    • toISO8601

      public String toISO8601(Time t)
      Returns a timestamp in ISO 8601 format (yyyy-mm-ddThh:mm:ss+hh:mm).
      参数:
      t - Time to append in the date
      返回:
      The formatted date-time String.
    • toDate

      public Date toDate()
      Converts to Date, time of day set to 00:00:00.000.
      返回:
      java.util.Date