|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.lang.Number
gov.nasa.gsfc.commons.numerics.types.Sexagesimal
public class Sexagesimal
The Sexagesimal class stores a representation of a time in hours, minutes, seconds, and tenths of seconds. It accepts a time string in the format HH:MM:SS.S and converts it internally to a numeric representation. It allows the time to be stored, updated, and compared to. The time can also be converted to a string in the above format. TODO: This file needs to be cleaned up. There are a lot of methods (e.g. any compare methods not called compareTo which seem pretty useless.
This code was developed for NASA, Goddard Space Flight Center, Code 580 for the Instrument Remote Control (IRC) project.
| Field Summary | |
|---|---|
static int |
MAX_MINUTES
This constant represents the Maximum number of minutes allowed in a Sexagesimal object. |
static double |
MAX_SECONDS
This constant represents the Maximum number of seconds allowed in a Sexagesimal object. |
static double |
MIN
This constant represents the Minimum number of minutes and seconds allowed in a Sexagesimal object. |
static int |
NEG_SIGN
Represents a negative value of the sign. |
static String |
NEG_SIGN_STR
|
static int |
POS_SIGN
Represents a positive value of the sign. |
static String |
POS_SIGN_STR
|
| Constructor Summary | |
|---|---|
Sexagesimal()
Default class constructor. |
|
Sexagesimal(int sign,
int hours,
int minutes,
double seconds)
Class constructor |
|
Sexagesimal(String time)
Class constructor |
|
| Method Summary | |
|---|---|
byte |
byteValue()
Convert the time held in this Sexagesimal object to seconds. |
int |
compareTo(Object o)
Compare this object with the given object. |
static Sexagesimal |
convertDoubleToSexagesimal(double value)
converts a double value to a Sexagesimal |
double |
doubleValue()
Convert the time held in this Sexagesimal object to seconds. |
boolean |
equals(Sexagesimal otherTime)
Test if time value held in the Sexagesimal object passed to this method is equal to the time value held in this object. |
float |
floatValue()
Convert the time held in this Sexagesimal object to seconds. |
int |
getHours()
Get the number of hours held in this Sexagesimal object. |
int |
getMinutes()
Get the number of minutes held in this Sexagesimal object. |
double |
getSeconds()
Get the number of seconds held in this Sexagesimal object. |
int |
getSign()
Get the sign of this Sexagesimal object. |
boolean |
greaterThan(Sexagesimal time)
Test if time value held in the Sexagesimal object passed to this method is greater than the time value held in this object. |
boolean |
greaterThanOrEqual(Sexagesimal time)
Test if time value held in the Sexagesimal object passed to this method is equal to the time value held in this object. |
int |
hashCode()
|
int |
intValue()
Convert the time held in this Sexagesimal object to seconds. |
boolean |
lessThan(Sexagesimal time)
Test if time value held in the Sexagesimal object passed to this method is less than the time value held in this object. |
boolean |
lessThanOrEqual(Sexagesimal time)
Test if time value held in the Sexagesimal object passed to this method is less than or equal to the time value held in this object. |
long |
longValue()
Convert the time held in this Sexagesimal object to seconds. |
void |
setHours(int hours)
Set the number of hours held in this Sexagesimal object. |
void |
setMinutes(int minutes)
Set the number of minutes held in this Sexagesimal object. |
void |
setSeconds(double seconds)
Set the number of seconds held in this Sexagesimal object. |
void |
setSign(int sign)
Set the sign of the value. |
void |
setValue(String newTime)
Set the time held in the Sexagesimal object. |
short |
shortValue()
Convert the time held in this Sexagesimal object to seconds. |
String |
toString()
Convert the time held in a Sexagesimal object to a string in the format HH:MM:SS.S. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int POS_SIGN
public static final int NEG_SIGN
public static final int MAX_MINUTES
public static final double MAX_SECONDS
public static final double MIN
public static final String POS_SIGN_STR
public static final String NEG_SIGN_STR
| Constructor Detail |
|---|
public Sexagesimal()
public Sexagesimal(String time)
throws NumberFormatException
time - Initial time value in the format HH:MM:SS.S
NumberFormatException - - if the String argument is not in the
correct format or, if the minutes or seconds contained
in the argument are larger than their MAX or less than MIN
then a NumberFormatException
is thrown.
public Sexagesimal(int sign,
int hours,
int minutes,
double seconds)
throws IllegalArgumentException
sign - Sign (positive or negative) of the value,
normally set as POS_SIGN or NEG_SIGNhours - Initial hours valueminutes - Initial minutes valueseconds - Initial seconds value
IllegalArgumentException - if the minutes or seconds
contained in this Sexagesimal
object are larger than their
MAX or less than MIN then an
exception is thrown.| Method Detail |
|---|
public void setValue(String newTime)
throws NumberFormatException
newTime - New time value in the format HH:MM:SS.S
NumberFormatException - if the minutes or seconds
contained in this Sexagesimal object are larger than their MAX
or less than MIN then an exception is thrown.public String toString()
toString in class Objectpublic void setSign(int sign)
sign - the new sign of the value, normally POS_SIGN or NEG_SIGNpublic void setHours(int hours)
hours - New hours value
public void setMinutes(int minutes)
throws IllegalArgumentException
minutes - New minutes value
IllegalArgumentException - - if the minutes passed in
are larger than their MAX or less than MIN
then an exception
is thrown.
public void setSeconds(double seconds)
throws IllegalArgumentException
seconds - New seconds value
IllegalArgumentException - - if the seconds passed in
are larger than their MAX or less than MIN
then an exception
is thrown.public int getSign()
public int getHours()
public int getMinutes()
public double getSeconds()
public boolean equals(Sexagesimal otherTime)
otherTime - The Sexagesimal to be tested
public int hashCode()
hashCode in class Objectpublic boolean lessThan(Sexagesimal time)
otherTime - The Sexagesimal to be tested
public boolean greaterThan(Sexagesimal time)
otherTime - The Sexagesimal to be tested
public boolean lessThanOrEqual(Sexagesimal time)
otherTime - The Sexagesimal to be tested
public boolean greaterThanOrEqual(Sexagesimal time)
otherTime - The Sexagesimal to be tested
public static Sexagesimal convertDoubleToSexagesimal(double value)
public int intValue()
intValue in class Numberpublic float floatValue()
floatValue in class Numberpublic long longValue()
longValue in class Numberpublic short shortValue()
shortValue in class Numberpublic byte byteValue()
byteValue in class Numberpublic double doubleValue()
doubleValue in class Numberpublic int compareTo(Object o)
compareTo in interface Comparableo - the object to be compared
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||