X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=crawler%2Fkiss%2Fsrc%2Forg%2Fwamblee%2Fcrawler%2Fkiss%2FTime.java;h=6679223bf3af77d14d3d462ca6f9a0e9e61bac88;hb=9d2a49c65872cd9330670a3cace19faf493df04d;hp=b2f95f058ce7dd9a261ae644220535677ce409c6;hpb=76827fb7e4bf7e1ecc0b2ef01a75c5751a915964;p=utils diff --git a/crawler/kiss/src/org/wamblee/crawler/kiss/Time.java b/crawler/kiss/src/org/wamblee/crawler/kiss/Time.java index b2f95f05..6679223b 100644 --- a/crawler/kiss/src/org/wamblee/crawler/kiss/Time.java +++ b/crawler/kiss/src/org/wamblee/crawler/kiss/Time.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.crawler.kiss; @@ -20,36 +20,67 @@ import java.text.DecimalFormat; import java.text.NumberFormat; /** - * + * TIme at which a program starts or ends. */ public class Time { - - private int _hour; - private int _minute; - - public Time(int aHour, int aMinute) { + + /** + * Number of seconds per minute. + */ + private static final double SECONDS_PER_MINUTE = 60.0; + + /** + * Hour of the time. + */ + private int _hour; + + /** + * Minute of the hour. + */ + private int _minute; + + /** + * Constructs the time. + * @param aHour Hour. + * @param aMinute Minute. + */ + public Time(int aHour, int aMinute) { _hour = aHour; _minute = aMinute; } - - public int getHour() { - return _hour; + + /** + * Gets the hour. + * @return Hour. + */ + public int getHour() { + return _hour; } - - public int getMinute() { - return _minute; + + /** + * Gets te minute. + * @return Minute. + */ + public int getMinute() { + return _minute; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see java.lang.Object#toString() */ @Override public String toString() { NumberFormat format = new DecimalFormat("00"); - return format.format(_hour) + ":" + format.format(_minute); + return format.format(_hour) + ":" + format.format(_minute); } - + + /** + * Convert time to floating point value. Useful for comparing two times. + * @return Converted value. + */ float asFloat() { - return (float)_hour + (float)_minute/(float)60.0; + return (float) _hour + (float) _minute / (float) SECONDS_PER_MINUTE; } }