1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet.shopping.model.impl;
16  
17  import com.liferay.portal.kernel.util.CalendarUtil;
18  import com.liferay.portlet.shopping.model.ShoppingCoupon;
19  
20  import java.util.Date;
21  
22  /**
23   * <a href="ShoppingCouponImpl.java.html"><b><i>View Source</i></b></a>
24   *
25   * @author Brian Wing Shun Chan
26   */
27  public class ShoppingCouponImpl
28      extends ShoppingCouponModelImpl implements ShoppingCoupon {
29  
30      public ShoppingCouponImpl() {
31      }
32  
33      public boolean hasValidDateRange() {
34          if (hasValidStartDate() && hasValidEndDate()) {
35              return true;
36          }
37          else {
38              return false;
39          }
40      }
41  
42      public boolean hasValidEndDate() {
43          if (getEndDate() != null) {
44              Date now = new Date();
45  
46              if (now.after(getEndDate())) {
47                  return false;
48              }
49          }
50  
51          return true;
52      }
53  
54      public boolean hasValidStartDate() {
55          Date now = new Date();
56  
57          if (CalendarUtil.beforeByDay(now, getStartDate())) {
58              return false;
59          }
60          else {
61              return true;
62          }
63      }
64  
65  }