View Javadoc
1   /*
2    * Copyright 2008-2009 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
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,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.ole.pdp.businessobject.options;
17  
18  import java.sql.Timestamp;
19  import java.util.Calendar;
20  import java.util.Date;
21  import java.util.GregorianCalendar;
22  
23  import org.kuali.ole.sys.context.SpringContext;
24  import org.kuali.rice.core.api.datetime.DateTimeService;
25  import org.kuali.rice.krad.valuefinder.ValueFinder;
26  
27  public class PaymentProcessTimestampFinder implements ValueFinder {
28  
29  
30      /**
31       * @see org.kuali.rice.krad.valuefinder.ValueFinder#getValue()
32       */
33      public String getValue() {
34          // we create a search criteria to get te payment processes in tha last 4 months
35          DateTimeService dateTimeService = SpringContext.getBean(DateTimeService.class);
36          GregorianCalendar calendarFourMonthsAgo = new GregorianCalendar();
37          calendarFourMonthsAgo.setTime(new Date());
38          calendarFourMonthsAgo.add(Calendar.MONTH, -4);
39  
40          // one day was added to the current date becuase the ".." wildcard on date will give us the results with a date greater or
41          // equal with the beginning date and less than the end date.
42          GregorianCalendar calendarNow = new GregorianCalendar();
43          calendarNow.setTime(new Date());
44          calendarNow.add(Calendar.DATE, +1);
45          String now = dateTimeService.toDateString(new Timestamp(calendarNow.getTimeInMillis()));
46          String fourMonthsAgo = dateTimeService.toDateString(new Timestamp(calendarFourMonthsAgo.getTimeInMillis()));
47  
48          String processTimestampValue = fourMonthsAgo + ".." + now;
49          return processTimestampValue;
50      }
51  
52  }