com.ail.util
Class DateOfBirth

java.lang.Object
  extended by com.ail.core.Type
      extended by com.ail.util.DateOfBirth
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class DateOfBirth
extends Type

Version:
$Revision: 1.1 $
See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.ail.core.Type
jXPathContext, NOT_PERSISTED
 
Constructor Summary
DateOfBirth()
          Default Constructor.
DateOfBirth(java.util.Date dob)
          Constructor
DateOfBirth(int year, int month, int day)
          Constructor to build a data of birth for a specific date.
 
Method Summary
 int ageAtDate(java.util.Date then)
          Return the age at a specific date.
 int currentAge()
          Return the current age
 java.util.Date getDate()
          Get the dob as a dat
 java.lang.String getDateAsString()
          Fetch the date in the format defined for the default locale.
 java.lang.String getDateAsString(java.util.Locale locale)
          Fetch the date in the locale defined format.
 java.lang.String getDateAsString(java.lang.String format)
          Fetch the date as a String in a specified format.
 void setDate(java.util.Date date)
          Set the date of birth
 void setDateAsString(java.lang.String date)
          Set the date from a string in the format defined for the default locale.
 void setDateAsString(java.lang.String date, java.util.Locale locale)
          Set the date from a string in the locale defined date format.
 void setDateAsString(java.lang.String date, java.lang.String format)
          Set the date from a string in the locale defined date format.
 
Methods inherited from class com.ail.core.Type
addAttribute, clone, deleteLock, deleteSerialVersion, fetchJXPathContext, getAttribute, getAttribute, getAttributeCount, getForeignSystemId, getLock, getSerialVersion, getSystemId, hasLock, hasSerialVersion, hasSystemId, isPersisted, markAsNotPersisted, mergeWithDataFrom, removeAttribute, removeAttribute, setAttribute, setForeignSystemId, setLock, setSerialVersion, setSystemId, xpathGet, xpathGet, xpathIterate, xpathSet
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateOfBirth

public DateOfBirth()
Default Constructor.


DateOfBirth

public DateOfBirth(java.util.Date dob)
Constructor

Parameters:
dob -

DateOfBirth

public DateOfBirth(int year,
                   int month,
                   int day)
Constructor to build a data of birth for a specific date.

Parameters:
year - Four digit year
month - Month number (0-11)
day - Day in month
Method Detail

getDate

public java.util.Date getDate()
Get the dob as a dat

Returns:
The date of birth

setDate

public void setDate(java.util.Date date)
Set the date of birth

Parameters:
date - The data of birth

getDateAsString

public java.lang.String getDateAsString()
Fetch the date in the format defined for the default locale.

Returns:
A string in the locale defined format.

setDateAsString

public void setDateAsString(java.lang.String date)
                     throws java.text.ParseException
Set the date from a string in the format defined for the default locale.

Parameters:
date - The date as a String
Throws:
java.text.ParseException - If the String does not represent a valid date in this locale.

getDateAsString

public java.lang.String getDateAsString(java.util.Locale locale)
Fetch the date in the locale defined format.

Parameters:
locale - Locale to format date for.
Returns:
A string in the locale defined format.

setDateAsString

public void setDateAsString(java.lang.String date,
                            java.util.Locale locale)
                     throws java.text.ParseException
Set the date from a string in the locale defined date format.

Parameters:
date - The date as a String
locale - The locale the date string is in
Throws:
java.text.ParseException - If the String does not represent a valid date in this locale.

getDateAsString

public java.lang.String getDateAsString(java.lang.String format)
Fetch the date as a String in a specified format.

Parameters:
format - The format of the date String required SimpleDateFormat
Returns:
A string in the locale defined format.

setDateAsString

public void setDateAsString(java.lang.String date,
                            java.lang.String format)
                     throws java.text.ParseException
Set the date from a string in the locale defined date format.

Parameters:
date - The date as a String
locale - The locale the date string is in
Throws:
java.text.ParseException - If the String does not represent a valid date in this locale.

currentAge

public int currentAge()
Return the current age

Returns:
Current age in years.

ageAtDate

public int ageAtDate(java.util.Date then)
Return the age at a specific date.

Parameters:
then - The date the age should be calculate for.
Returns:
Current age in years.