public class Person
private final Date birthDate;
// others fields omitted
public boolean isBabyBoomer() {
Calendar gmtCal =
Calendar.getInstance(TimeZone.getTimeZone("GMT"));
gmtCal.set(1946,Calendar.JANUARY,1,0,0,0);
Date boomStart =gmtCal.getTime();
gmtCal.set(1965,Calendar.JANUARY,1,0,0,0);
Date boomEnd = gmtCal.getTime();
return birthDate.compareTo(boomStart) >= 0 && //where is Birthdate instance
// to compare
birthDate.compareTo(boomEnd) < 0;
}
}
- when and how the program gets birthdate instance ?
- Do they omitted coding process for that instance ?
- For what purpose they compared results with zero(>= and < ) inside return ?
- Can not we use simple return without using zeros integer (boolean only for testing) ?