[FIRSTCUP-12] Method getAgeDifference of DukesBirthdayBean returns wrong value Created: 13/May/13  Updated: 11/Jun/13  Resolved: 11/Jun/13

Status: Resolved
Project: firstcup
Component/s: examples
Affects Version/s: current
Fix Version/s: 7.0.1

Type: Bug Priority: Major
Reporter: Johann_Kropf Assignee: Ian Evans
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Netbeans 7.3, Your Firstcup Cup, April 2012, Windows 7 64bit



 Description   

The method getAgeDifference of the enterprise bean class DukesBirthdayBean returns wrong values. That's because 1. theirBirthday and dukesBirthday are not at the same year when compared and 2. if the user is younger (<0) and dukesBirthday is after the user's one the ageDifference should be reduced.

I have added the following code:

// Bring the dates to the same year (the dukes Year)
theirBirthday.add(Calendar.YEAR, ageDifference);

// Check to see if Duke's birthday occurs before the user's when the user is older. If so,
// subtract one from the age difference
if (dukesBirthday.before(theirBirthday) && (ageDifference > 0)) {
ageDifference--;
}
// Check to see if Duke's birthday occurs after the user's when the user is younger. If so,
// subtract one from the age difference
if (dukesBirthday.after(theirBirthday) && (ageDifference < 0)) {
ageDifference++;
}



 Comments   
Comment by Ian Evans [ 11/Jun/13 ]

Updated the source with the fix, and it is in version 7.0.1, in the Java EE 7 SDK.

Generated at Mon Aug 31 22:41:34 UTC 2015 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.