net.sourceforge.jaulp.date
Class Age

java.lang.Object
  extended by net.sourceforge.jaulp.date.Age
All Implemented Interfaces:
java.io.Serializable

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

Helper class to present one long value from a calculate two Dates in a human readable string.

Version:
1.0
Author:
Asterios Raptis
See Also:
Serialized Form

Field Summary
static long ONE_DAY
          The Constant ONE_DAY.
static long ONE_DEFAULT_MONTH
          The Constant ONE_DEFAULT_MONTH.
static long ONE_HOUR
          The Constant ONE_HOUR.
static long ONE_MINUTE
          The Constant ONE_MINUTE.
static long ONE_SECOND
          The Constant ONE_SECOND.
static long ONE_YEAR
          The Constant ONE_YEAR.
 
Constructor Summary
Age(java.util.Date birthday)
          Instantiates a new Age object from the given Date objects.
Age(java.util.Date birthday, java.util.Date till)
          Instantiates a new Age object from the given Date objects.
Age(long elapsed)
          Default constructor.
 
Method Summary
 double calculateInDays()
          Calculate in days.
 double calculateInDays(long time)
          Calculate in days.
 double calculateInDefaultMonth()
          Calculate in default month.
 double calculateInDefaultMonth(long time)
          Calculate in default month.
 double calculateInHours()
          Calculate in hours.
 double calculateInHours(long time)
          Calculate in hours.
 double calculateInMinutes()
          Calculate in minutes.
 double calculateInMinutes(long time)
          Calculate in minutes.
 double calculateInSeconds()
          Calculate in seconds.
 double calculateInSeconds(long time)
          Calculate in minutes.
 double calculateInYears()
          Calculate in years.
 double calculateInYears(long el)
          Calculate in years.
 int[] calculateInYearsMonthsDaysHoursMinutesAndSeconds()
          Calculate in years months days hours minutes and seconds.
 int[] calculateInYearsMonthsDaysHoursMinutesAndSeconds(long compute)
          Calculate in years months days hours minutes and seconds.
 java.lang.String getHumanReadableAge()
          Gets a human readable string from the age.
 java.lang.String getHumanReadableAge(int[] readableAge)
          Gets a human readable string from the age.
 java.lang.String printHumanReadableAge()
          Deprecated. Use instead the method Age.getHumanReadableAge().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ONE_SECOND

public static final long ONE_SECOND
The Constant ONE_SECOND.

See Also:
Constant Field Values

ONE_MINUTE

public static final long ONE_MINUTE
The Constant ONE_MINUTE.

See Also:
Constant Field Values

ONE_HOUR

public static final long ONE_HOUR
The Constant ONE_HOUR.

See Also:
Constant Field Values

ONE_DAY

public static final long ONE_DAY
The Constant ONE_DAY.

See Also:
Constant Field Values

ONE_DEFAULT_MONTH

public static final long ONE_DEFAULT_MONTH
The Constant ONE_DEFAULT_MONTH.

See Also:
Constant Field Values

ONE_YEAR

public static final long ONE_YEAR
The Constant ONE_YEAR.

See Also:
Constant Field Values
Constructor Detail

Age

public Age(java.util.Date birthday)
Instantiates a new Age object from the given Date objects.

Parameters:
birthday - The birthday.

Age

public Age(java.util.Date birthday,
           java.util.Date till)
Instantiates a new Age object from the given Date objects.

Parameters:
birthday - The birthday.
till - The point where the Age stops.

Age

public Age(long elapsed)
Default constructor.

Parameters:
elapsed - The elapsed time in long.
Method Detail

calculateInDays

public double calculateInDays()
Calculate in days.

Returns:
the double

calculateInDays

public double calculateInDays(long time)
Calculate in days.

Parameters:
time - the time
Returns:
the double

calculateInDefaultMonth

public double calculateInDefaultMonth()
Calculate in default month.

Returns:
the double

calculateInDefaultMonth

public double calculateInDefaultMonth(long time)
Calculate in default month. It is calculated that one default month is 30 days.

Parameters:
time - the time.
Returns:
the result as double.

calculateInHours

public double calculateInHours()
Calculate in hours.

Returns:
the double

calculateInHours

public double calculateInHours(long time)
Calculate in hours.

Parameters:
time - the time
Returns:
the double

calculateInMinutes

public double calculateInMinutes()
Calculate in minutes.

Returns:
the double

calculateInMinutes

public double calculateInMinutes(long time)
Calculate in minutes.

Parameters:
time - the time
Returns:
the double

calculateInSeconds

public double calculateInSeconds()
Calculate in seconds.

Returns:
the double

calculateInSeconds

public double calculateInSeconds(long time)
Calculate in minutes.

Parameters:
time - the time
Returns:
the double

calculateInYears

public double calculateInYears()
Calculate in years.

Returns:
the double

calculateInYears

public double calculateInYears(long el)
Calculate in years.

Parameters:
el - The time.
Returns:
the double

calculateInYearsMonthsDaysHoursMinutesAndSeconds

public int[] calculateInYearsMonthsDaysHoursMinutesAndSeconds()
Calculate in years months days hours minutes and seconds.

Returns:
the int[] Returns an int array where the first element is the years the second element the months the third element the days then hours, minutes and seconds.

calculateInYearsMonthsDaysHoursMinutesAndSeconds

public int[] calculateInYearsMonthsDaysHoursMinutesAndSeconds(long compute)
Calculate in years months days hours minutes and seconds.

Parameters:
compute - The long to calculate.
Returns:
the int[] Returns an int array where the first element is the years the second element the months the third element the days then hours, minutes and seconds.

getHumanReadableAge

public java.lang.String getHumanReadableAge()
Gets a human readable string from the age.

Returns:
Returns a human readable string from the age.

getHumanReadableAge

public java.lang.String getHumanReadableAge(int[] readableAge)
Gets a human readable string from the age.

Parameters:
readableAge - The int array with the age values.
Returns:
Returns a human readable string from the age.

printHumanReadableAge

@Deprecated
public java.lang.String printHumanReadableAge()
Deprecated. Use instead the method Age.getHumanReadableAge().

Gets a human readable string from the age.

Returns:
Returns a human readable string from the age.


Copyright © 2010. All Rights Reserved.