選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

CalendarDateRange.java 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * Copyright 2000-2016 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.v7.ui.components.calendar;
  17. import java.io.Serializable;
  18. import java.util.Date;
  19. import java.util.TimeZone;
  20. /**
  21. * Class for representing a date range.
  22. *
  23. * @since 7.1.0
  24. * @author Vaadin Ltd.
  25. *
  26. *
  27. * @deprecated As of 8.0, no replacement available.
  28. */
  29. @SuppressWarnings("serial")
  30. @Deprecated
  31. public class CalendarDateRange implements Serializable {
  32. private Date start;
  33. private Date end;
  34. private final transient TimeZone tz;
  35. /**
  36. * Constructor
  37. *
  38. * @param start
  39. * The start date and time of the date range
  40. * @param end
  41. * The end date and time of the date range
  42. */
  43. public CalendarDateRange(Date start, Date end, TimeZone tz) {
  44. super();
  45. this.start = start;
  46. this.end = end;
  47. this.tz = tz;
  48. }
  49. /**
  50. * Get the start date of the date range
  51. *
  52. * @return the start Date of the range
  53. */
  54. public Date getStart() {
  55. return start;
  56. }
  57. /**
  58. * Get the end date of the date range
  59. *
  60. * @return the end Date of the range
  61. */
  62. public Date getEnd() {
  63. return end;
  64. }
  65. /**
  66. * Is a date in the date range
  67. *
  68. * @param date
  69. * The date to check
  70. * @return true if the date range contains a date start and end of range
  71. * inclusive; false otherwise
  72. */
  73. public boolean inRange(Date date) {
  74. if (date == null) {
  75. return false;
  76. }
  77. return date.compareTo(start) >= 0 && date.compareTo(end) <= 0;
  78. }
  79. /*
  80. * (non-Javadoc)
  81. *
  82. * @see java.lang.Object#toString()
  83. */
  84. @Override
  85. public String toString() {
  86. return "CalendarDateRange [start=" + start + ", end=" + end + "]";
  87. }
  88. }