1 package org.kuali.ole.ingest.function;
2
3 import org.apache.log4j.Logger;
4 import org.kuali.rice.krms.framework.engine.Function;
5
6 import java.text.DateFormat;
7 import java.text.ParseException;
8 import java.text.SimpleDateFormat;
9 import java.util.ArrayList;
10 import java.util.Date;
11
12
13
14
15 public class OleCurrentDateComparison implements Function {
16 private static final Logger LOG = Logger.getLogger(OleCurrentDateComparison.class);
17
18
19
20
21
22 @Override
23 public Object invoke(Object... arguments) {
24 LOG.info(" --------- Inside OleCurrentDateComparison ------------");
25 boolean comparison = false;
26 if(arguments!=null && arguments.length==1){
27 Object object = arguments[0];
28 if(object==null)
29 return false;
30 Date expirationDate = null;
31 if(object instanceof String){
32 DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy hh:mm:ss");
33 try {
34 expirationDate= (Date)formatter.parse((String)object);
35 } catch (ParseException e) {
36 e.printStackTrace();
37 }
38
39 }else{
40 expirationDate =(Date)object;
41 }
42 comparison =checkMembershipExpirationDate(expirationDate);
43 }
44
45 return comparison;
46 }
47
48
49
50
51
52
53 private boolean checkMembershipExpirationDate(Date expDate){
54 Date curDat = new Date();
55 if(expDate!=null && curDat.compareTo(expDate)>=0){
56 return true;
57 }
58 return false;
59 }
60 }