net.sf.marineapi.nmea.util
Class Date

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

public class Date
extends Object

Represents a calendar date (day-month-year) transmitted in sentences that implement DateSentence.

Version:
$Revision: 104 $
Author:
Kimmo Tuukkanen
See Also:
DateSentence, Time

Field Summary
static int PIVOT_YEAR
          A pivot value that is used to determine century for two-digit year values.
 
Constructor Summary
Date()
          Creates a new instance of Date using the current date.
Date(int year, int month, int day)
          Constructor with date values.
 
Method Summary
 boolean equals(Object obj)
           
 int getDay()
          Get day of month.
 int getMonth()
          Get month, valid values are 1-12 where 1 denotes January, 2 denotes February etc.
 int getYear()
          Get year.
 int hashCode()
           
 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.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

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.

See Also:
Constant Field Values
Constructor Detail

Date

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


Date

public Date(int year,
            int month,
            int day)
Constructor with date values.

Parameters:
year - Year, two or four digit value [0..99] or [1000..9999]
month - Month [1..12]
day - Day [1..31]
Throws:
IllegalArgumentException - If any of the parameter is out of bounds.
Method Detail

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

getDay

public int getDay()
Get day of month.

Returns:
the day

getMonth

public int getMonth()
Get month, valid values are 1-12 where 1 denotes January, 2 denotes February etc.

Returns:
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.

Returns:
The four-digit year
See Also:
PIVOT_YEAR

hashCode

public int hashCode()
Overrides:
hashCode in class Object

setDay

public void setDay(int day)
Set day of month.

Parameters:
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.

Parameters:
month - the month to set
Throws:
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 {link #PIVOT_YEAR}. Values lower than or equal to pivot are added to 2000, while values greater than pivot are added to 1900.

Parameters:
year - Year to set, two or four digit value.
Throws:
IllegalArgumentException - If specified value is negative or three-digit value.

toString

public String toString()
Overrides:
toString in class Object


Copyright (C) 2010-2011 Java Marine API author(s). All Rights Reserved.