You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CalendarEntry.java 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. package com.itmill.toolkit.terminal.gwt.client.ui;
  2. import java.util.Date;
  3. import com.itmill.toolkit.terminal.gwt.client.DateTimeService;
  4. public class CalendarEntry {
  5. private Date start;
  6. private Date end;
  7. private String title;
  8. private String description;
  9. private boolean notime;
  10. public CalendarEntry(Date start, Date end, String title,
  11. String description, boolean notime) {
  12. if (notime) {
  13. Date d = new Date(start.getTime());
  14. d.setSeconds(0);
  15. d.setMinutes(0);
  16. this.start = d;
  17. if (end != null) {
  18. d = new Date(end.getTime());
  19. d.setSeconds(0);
  20. d.setMinutes(0);
  21. this.end = d;
  22. } else {
  23. end = start;
  24. }
  25. } else {
  26. this.start = start;
  27. this.end = end;
  28. }
  29. this.title = title;
  30. this.description = description;
  31. this.notime = notime;
  32. }
  33. public CalendarEntry(Date start, Date end, String title, String description) {
  34. this(start, end, title, description, false);
  35. }
  36. public Date getStart() {
  37. return start;
  38. }
  39. public void setStart(Date start) {
  40. this.start = start;
  41. }
  42. public Date getEnd() {
  43. return end;
  44. }
  45. public void setEnd(Date end) {
  46. this.end = end;
  47. }
  48. public String getTitle() {
  49. return title;
  50. }
  51. public void setTitle(String title) {
  52. this.title = title;
  53. }
  54. public String getDescription() {
  55. return description;
  56. }
  57. public void setDescription(String description) {
  58. this.description = description;
  59. }
  60. public boolean isNotime() {
  61. return notime;
  62. }
  63. public void setNotime(boolean notime) {
  64. this.notime = notime;
  65. }
  66. public String getStringForDate(Date d) {
  67. // TODO format from DateTimeService
  68. String s = "";
  69. if (!notime) {
  70. if (!DateTimeService.isSameDay(d, start)) {
  71. s += (start.getYear() + 1900) + "." + (start.getMonth() + 1)
  72. + "." + start.getDate() + " ";
  73. }
  74. int i = start.getHours();
  75. s += (i < 10 ? "0" : "") + i;
  76. s += ":";
  77. i = start.getMinutes();
  78. s += (i < 10 ? "0" : "") + i;
  79. if (!start.equals(end)) {
  80. s += " - ";
  81. if (!DateTimeService.isSameDay(start, end)) {
  82. s += (end.getYear() + 1900) + "." + (end.getMonth() + 1)
  83. + "." + end.getDate() + " ";
  84. }
  85. i = end.getHours();
  86. s += (i < 10 ? "0" : "") + i;
  87. s += ":";
  88. i = end.getMinutes();
  89. s += (i < 10 ? "0" : "") + i;
  90. }
  91. s += " ";
  92. }
  93. s += title;
  94. return s;
  95. }
  96. }