Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public boolean earlier(MyDate compared) {
- boolean retVal = false;
- if (this.year < compared.year)
- {
- //cazul in care compar 2010 luna 5 cu 2011 luna 6 = e clar ca e cel putin 1 an
- if (this.month < compared.month)
- {
- retVal = true;
- }
- // cazul in care lunile sunt egale la 2010 si 2011, trebuie verificata ziua
- // daca am 10 mai 2010, un an e cel mai aproape in 10 mai 2011 sau mai tarziu
- if (this.month == compared.month && this.day <= compared.day)
- {
- retVal = true;
- }
- }
- if (this.year > compared.year) // daca compar 10 mai 2011 cu 10 apr 2010
- {
- if (this.month > compared.month) //daca mai > aprilie = clar e cel putin 1 an
- {
- retVal = true;
- }
- if(this.month == compared.month && this.day >= compared.day)
- {
- retVal = true;
- }
- }
- return retVal;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement