001 /*
002 * Copyright 2011 The Kuali Foundation.
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.kuali.kfs.pdp.businessobject.options;
017
018 import java.sql.Timestamp;
019 import java.util.Calendar;
020 import java.util.Date;
021 import java.util.GregorianCalendar;
022
023 import org.kuali.kfs.sys.context.SpringContext;
024 import org.kuali.rice.kns.lookup.valueFinder.ValueFinder;
025 import org.kuali.rice.kns.service.DateTimeService;
026
027 public class PaymentProcessTimestampFinder implements ValueFinder {
028
029
030 /**
031 * @see org.kuali.rice.kns.lookup.valueFinder.ValueFinder#getValue()
032 */
033 public String getValue() {
034 // we create a search criteria to get te payment processes in tha last 4 months
035 DateTimeService dateTimeService = SpringContext.getBean(DateTimeService.class);
036 GregorianCalendar calendarFourMonthsAgo = new GregorianCalendar();
037 calendarFourMonthsAgo.setTime(new Date());
038 calendarFourMonthsAgo.add(Calendar.MONTH, -4);
039
040 // one day was added to the current date becuase the ".." wildcard on date will give us the results with a date greater or
041 // equal with the beginning date and less than the end date.
042 GregorianCalendar calendarNow = new GregorianCalendar();
043 calendarNow.setTime(new Date());
044 calendarNow.add(Calendar.DATE, +1);
045 String now = dateTimeService.toDateString(new Timestamp(calendarNow.getTimeInMillis()));
046 String fourMonthsAgo = dateTimeService.toDateString(new Timestamp(calendarFourMonthsAgo.getTimeInMillis()));
047
048 String processTimestampValue = fourMonthsAgo + ".." + now;
049 return processTimestampValue;
050 }
051
052 }