info.jonclark.util
Class TimeLength

java.lang.Object
  extended by info.jonclark.util.TimeLength

public class TimeLength
extends Object


Constructor Summary
TimeLength(Date start, Date end)
           
TimeLength(long millis)
           
TimeLength(long seconds, long millis)
           
TimeLength(long minutes, long seconds, long millis)
           
TimeLength(long hours, long minutes, long seconds, long millis)
           
TimeLength(long days, long hours, long minutes, long seconds, long millis)
           
 
Method Summary
 double getInDays()
           
 double getInHours()
           
 long getInMillis()
          Note: This method is equivalent to toLong()
 double getInMinutes()
           
 double getInSeconds()
           
 double getInYears()
           
static void main(String[] args)
           
static TimeLength parseTimeLength(String strInput)
           
 long toLong()
           
 String toString()
          Returns all unit components of the time length (including zero values).
 String toStringMultipleUnits(int nMaxUnits)
           
 String toStringSingleUnit()
          Finds the biggest unit possible that can be represented with a whole number and outputs a String in that unit of time length as a double to one decimal place of accuracy.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TimeLength

public TimeLength(long millis)
Parameters:
millis - The length of this time span in milliseconds

TimeLength

public TimeLength(long seconds,
                  long millis)

TimeLength

public TimeLength(long minutes,
                  long seconds,
                  long millis)

TimeLength

public TimeLength(long hours,
                  long minutes,
                  long seconds,
                  long millis)

TimeLength

public TimeLength(long days,
                  long hours,
                  long minutes,
                  long seconds,
                  long millis)

TimeLength

public TimeLength(Date start,
                  Date end)
Method Detail

getInYears

public double getInYears()

getInDays

public double getInDays()

getInHours

public double getInHours()

getInMinutes

public double getInMinutes()

getInSeconds

public double getInSeconds()

getInMillis

public long getInMillis()
Note: This method is equivalent to toLong()

Returns:

toLong

public long toLong()

parseTimeLength

public static TimeLength parseTimeLength(String strInput)

toStringSingleUnit

public String toStringSingleUnit()
Finds the biggest unit possible that can be represented with a whole number and outputs a String in that unit of time length as a double to one decimal place of accuracy.

e.g. 12.3 days or 2.5 minutes.


toStringMultipleUnits

public String toStringMultipleUnits(int nMaxUnits)

toString

public String toString()
Returns all unit components of the time length (including zero values).

e.g. 10 years, 0 days, 0 hours, 0 minutes, 29 seconds

Overrides:
toString in class Object
Returns:
A string of the above format containing all long values.

main

public static void main(String[] args)
                 throws Exception
Throws:
Exception