Guest User

Untitled

a guest
Jan 22nd, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. package com.example.circlecisample;
  2.  
  3. import java.util.Calendar;
  4.  
  5. public class Holiday {
  6.  
  7. private static final int DECEMBER = 12;
  8. private static final int DAY_OF_XMAS = 25;
  9. private static final int DAY_OF_XMAS_NIGHT = 24;
  10.  
  11. public String sayXmas() {
  12. int month = getCurrentMonth();
  13. int day = getCurrentDayOfMonth();
  14.  
  15. if (month == DECEMBER && (day == DAY_OF_XMAS || day == DAY_OF_XMAS_NIGHT)) {
  16. return "Merry Xmas";
  17. } else {
  18. return "Today is not Xmas";
  19. }
  20. }
  21.  
  22. protected int getCurrentMonth() {
  23. Calendar calendar = Calendar.getInstance();
  24. return calendar.get(Calendar.MONTH) + 1;
  25. }
  26.  
  27. protected int getCurrentDayOfMonth() {
  28. Calendar calendar = Calendar.getInstance();
  29. return calendar.get(Calendar.DAY_OF_MONTH);
  30. }
  31. }
Add Comment
Please, Sign In to add comment