[WTF] Eureka!

If you think you know how to work out the age of a person, based on his date of birth, it’d be better to review your concepts about implementing this functionality. Enjoy the code!!

    public UserImpl( UserTO user, String status ) {
        _user = user;
        _status = status;

        _age = 0;
        Calendar today = Calendar.getInstance();
        Calendar birthdate = Calendar.getInstance();
        birthdate.setTimeInMillis( getBirthdate().getTime() );
        birthdate.roll( Calendar.YEAR, 1 );
        while ( today.after( birthdate ) ) {
            birthdate.roll( Calendar.YEAR, 1 );
            _age++;
        }
    }
Share and Enjoy:
  • Print
  • Digg
  • del.icio.us
  • Reddit
Leave a comment

0 Comments.

Leave a Reply


[ Ctrl + Enter ]

Comment moderation is enabled. Your comment may take some time to appear.