001/*
002 * Copyright 2008-2009 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 */
016package org.kuali.ole.pdp.businessobject.options;
017
018import java.sql.Timestamp;
019import java.util.Calendar;
020import java.util.Date;
021import java.util.GregorianCalendar;
022
023import org.kuali.ole.sys.context.SpringContext;
024import org.kuali.rice.core.api.datetime.DateTimeService;
025import org.kuali.rice.krad.valuefinder.ValueFinder;
026
027public class PaymentProcessTimestampFinder implements ValueFinder {
028
029
030    /**
031     * @see org.kuali.rice.krad.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}