Advertisement
Guest User

Untitled

a guest
Jul 19th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. public boolean earlier(MyDate compared) {
  2. boolean retVal = false;
  3. if (this.year < compared.year)
  4. {
  5.  
  6. //cazul in care compar 2010 luna 5 cu 2011 luna 6 = e clar ca e cel putin 1 an
  7. if (this.month < compared.month)
  8. {
  9. retVal = true;
  10. }
  11.  
  12. // cazul in care lunile sunt egale la 2010 si 2011, trebuie verificata ziua
  13. // daca am 10 mai 2010, un an e cel mai aproape in 10 mai 2011 sau mai tarziu
  14.  
  15. if (this.month == compared.month && this.day <= compared.day)
  16. {
  17. retVal = true;
  18. }
  19. }
  20.  
  21.  
  22. if (this.year > compared.year) // daca compar 10 mai 2011 cu 10 apr 2010
  23. {
  24. if (this.month > compared.month) //daca mai > aprilie = clar e cel putin 1 an
  25. {
  26. retVal = true;
  27. }
  28.  
  29. if(this.month == compared.month && this.day >= compared.day)
  30. {
  31. retVal = true;
  32. }
  33. }
  34. return retVal;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement