View Javadoc
1   package org.kuali.ole.docstore.document;
2   
3   import org.apache.commons.net.ntp.TimeStamp;
4   import org.kuali.ole.docstore.model.xmlpojo.ingest.RequestDocument;
5   import org.kuali.ole.docstore.model.xmlpojo.ingest.ResponseDocument;
6   import org.slf4j.Logger;
7   import org.slf4j.LoggerFactory;
8   
9   import java.sql.Timestamp;
10  import java.text.DateFormat;
11  import java.text.ParseException;
12  import java.text.SimpleDateFormat;
13  import java.util.Date;
14  
15  /**
16   * Created with IntelliJ IDEA.
17   * User: mjagan
18   * Date: 6/26/13
19   * Time: 3:15 PM
20   * To change this template use File | Settings | File Templates.
21   */
22  public abstract class AbstractDocumentManager implements DocumentManager {
23  
24      private static final Logger LOG = LoggerFactory.getLogger(AbstractDocumentManager.class);
25      public Date getDate(String date) {
26          try {
27              if (!"".equals(date) && date != null) {
28                  DateFormat df = new SimpleDateFormat("mm/dd/yyyy hh:mm:ss");
29                  Date parseDate = df.parse(date);
30                  return parseDate;
31              }
32          } catch (Exception e) {
33              try {
34                  if (!"".equals(date) && date != null) {
35                      DateFormat df = new SimpleDateFormat("mm/dd/yyyy");
36                      Date parseDate = df.parse(date);
37                      return parseDate;
38                  }
39              } catch (Exception e1) {
40                  LOG.info("Exception : ", e1);
41              }
42          }
43          return null;
44      }
45  
46      public void addResourceId(RequestDocument requestDocument, ResponseDocument respDoc) {
47  
48      }
49  
50  
51      public Timestamp getTimeStampFromString(String date) {
52          DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
53          Timestamp createdDate = null;
54          try {
55              createdDate = new Timestamp(df.parse(date).getTime());
56          } catch (ParseException e) {
57              LOG.info("Exception : ", e);
58          }
59          return createdDate;
60      }
61  }