jsky.coords
Class HMS

java.lang.Object
  extended by jsky.coords.HMS
All Implemented Interfaces:
java.io.Serializable

public class HMS
extends java.lang.Object
implements java.io.Serializable

Class representing a value of the form "hours:min:sec".

Version:
$Revision: 1.1 $
Author:
Allan Brighton
See Also:
Serialized Form

Constructor Summary
HMS()
          Default constructor: initialize to null values
HMS(double val)
          Initialize from a decimal hours value and calculate H:M:S.sss.
HMS(double hours, int min, double sec)
          Initialize with the given hours, minutes and seconds.
HMS(HMS hms)
          Copy constructor
HMS(java.lang.String s)
          Initialize from a string value, in format H:M:S.sss, hh, or H M S.
HMS(java.lang.String s, boolean hflag)
          Initialize from a string value, in format H:M:S.sss, hh, or H M S.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Define equality based on the value
 int getHours()
          Return the number of hours (not including minutes or seconds)
 int getMin()
          Return the number of minutes (not including hours or seconds)
 double getSec()
          Return the number of seconds (not including hours and minutes)
 byte getSign()
          Return the sign of the value
 double getVal()
          Return the value (fractional number of hours) as a double
 boolean isInitialized()
          Return true if this object has been initialized with a valid value
static void main(java.lang.String[] args)
          Test cases
 void set(double hours, int min, double sec)
          Set the hours, minutes and seconds.
 void setVal(double val)
          Set from a decimal value (hours) and calculate H:M:S.sss.
 java.lang.String toString()
          Return the value as a String in the form hh:mm:ss.sss.
 java.lang.String toString(boolean showSeconds)
          Return the value as a String in the form hh:mm:ss.sss, or if showSeconds is false, hh:mm.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HMS

public HMS()
Default constructor: initialize to null values


HMS

public HMS(double hours,
           int min,
           double sec)
Initialize with the given hours, minutes and seconds.


HMS

public HMS(double val)
Initialize from a decimal hours value and calculate H:M:S.sss.


HMS

public HMS(HMS hms)
Copy constructor


HMS

public HMS(java.lang.String s)
Initialize from a string value, in format H:M:S.sss, hh, or H M S. If the value is not in H:M:S and is not an integer (has a decimal point), assume the value is in deg convert to hours by dividing by 15. (Reason: some catalog servers returns RA in h:m:s while others return it in decimal deg.)


HMS

public HMS(java.lang.String s,
           boolean hflag)
Initialize from a string value, in format H:M:S.sss, hh, or H M S. If the value is not in H:M:S and is not an integer (has a decimal point), and hflag is true, assume the value is in deg and convert to hours by dividing by 15.

Parameters:
s - the RA string
hflag - if true, assume RA is always in hours, otherwise, if it has a decimal point, assume deg
Method Detail

set

public void set(double hours,
                int min,
                double sec)
Set the hours, minutes and seconds.


setVal

public void setVal(double val)
Set from a decimal value (hours) and calculate H:M:S.sss.


toString

public java.lang.String toString()
Return the value as a String in the form hh:mm:ss.sss. Seconds are formatted with leading zero if needed. The seconds are formatted with 3 digits of precision.

Overrides:
toString in class java.lang.Object

toString

public java.lang.String toString(boolean showSeconds)
Return the value as a String in the form hh:mm:ss.sss, or if showSeconds is false, hh:mm.


isInitialized

public boolean isInitialized()
Return true if this object has been initialized with a valid value


getHours

public int getHours()
Return the number of hours (not including minutes or seconds)


getMin

public int getMin()
Return the number of minutes (not including hours or seconds)


getSec

public double getSec()
Return the number of seconds (not including hours and minutes)


getVal

public double getVal()
Return the value (fractional number of hours) as a double


getSign

public byte getSign()
Return the sign of the value


equals

public boolean equals(java.lang.Object obj)
Define equality based on the value

Overrides:
equals in class java.lang.Object

main

public static void main(java.lang.String[] args)
Test cases