Advertisement
Guest User

Untitled

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