Advertisement
Guest User

Untitled

a guest
Sep 21st, 2014
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1.  
  2. public class MyDateMethod
  3. {
  4. private int day;
  5. private int month;
  6. private int year;
  7.  
  8. public MyDateMethod(int day, int month, int year)
  9. {
  10. this.day = day;
  11. this.month = month;
  12. this.year = year;
  13. }
  14.  
  15. public MyDateMethod()
  16. {
  17. this.day = 3;
  18. this.month = 9;
  19. this.year = 14;
  20. }
  21.  
  22. public int getDay()
  23. {
  24. return day;
  25. }
  26. public void setDay(int d)
  27. {
  28. day = d;
  29. }
  30. public int getMonth()
  31. {
  32. return month;
  33. }
  34. public void setMonth(int m)
  35. {
  36. month = m;
  37. }
  38. public int getYear()
  39. {
  40. return year;
  41. }
  42. public void setYear(int y)
  43. {
  44. year = y;
  45. }
  46. public String displayDate ()
  47. { return day+"/"+month+"/"+year;
  48. }
  49. public String getMonthName()
  50. {
  51.  
  52. switch (month)
  53. {
  54. case 1:
  55. return "January";
  56. case 2:
  57. return "February";
  58. case 3:
  59. return "March";
  60. case 4:
  61. return "April";
  62. case 5:
  63. return "May";
  64. case 6:
  65. return "June";
  66. case 7:
  67. return "July";
  68. case 8:
  69. return "August";
  70. case 9:
  71. return "September";
  72. case 10:
  73. return "October";
  74. case 11:
  75. return "November";
  76. case 12:
  77. return "December";
  78.  
  79. default:
  80. return "Error";
  81.  
  82.  
  83. }
  84.  
  85.  
  86. }
  87.  
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement