Hi,
i doesn't work exactly. My Method:
@Transient
| public Integer getAge() {
| // Create a calendar object with the date of birth
| Calendar dateOfBirth = getBirthdate();
|
| // Create a calendar object with today's date
| Calendar today = Calendar.getInstance();
| today.setTimeZone(TimeZone.getTimeZone("UTC"));
|
| // Get age based on year
| Integer age = new Integer(today.get(Calendar.YEAR) -
dateOfBirth.get(Calendar.YEAR));
|
| // Add the tentative age to the date of birth to get this year's
birthday
| dateOfBirth.add(Calendar.YEAR, age);
|
| // If this year's birthday has not happened yet, subtract one from age
| if (today.before(dateOfBirth))
| {
| age--;
| dateOfBirth.add(Calendar.YEAR, +1);
| }
| dateOfBirth.add(Calendar.YEAR, -age);
| return age;
| }
When i use this code in public static void main method it will work and show
the real age. When i use this code in the entity EJB this method will not work.
It fails on today.before(dateOfBirth). In the main method this is true in the
ejb it is false. WHY??? ARGH!
Thanks for any advice!
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3933473#3933473
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3933473
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user