1    package com.instantbank.collections.util;
2    
3    import java.util.Calendar;
4    import java.util.Date;
5    import java.sql.PreparedStatement;
6    import java.sql.ResultSet;
7    import java.sql.SQLException;
8    import javax.naming.NamingException;
9    
10   /**
11    * A Class class.
12    * <P>
13    *
14    * @author Guillermo Posse
15    */
16   public class DateUtils extends Object {
17     /**
18      * Constructor
19      */
20     public DateUtils() { }
21   
22   
23     public static Date today() {
24       Calendar rightNow = Calendar.getInstance();
25       int year = rightNow.get(Calendar.YEAR);
26       int month = rightNow.get(Calendar.MONTH);
27       int day = rightNow.get(Calendar.DATE);
28       rightNow.clear();
29       rightNow.set(year, month, day);
30       return rightNow.getTime();
31     }
32   
33   
34     public static Date rightNow() {
35       Calendar rightNow = Calendar.getInstance();
36       return rightNow.getTime();
37     }
38   
39   
40     public static Date processDate(long lCompanyID) throws SQLException, NamingException {
41       DataAccess da = new DataAccess();
42       ResultSet rs = null;
43       PreparedStatement pstmt = null;
44       Date procDate = null;
45   
46       try {
47         da.connect();
48         pstmt = da.getConnection().prepareStatement("SELECT pd_process_date FROM process_date WHERE pd_cmp_id = ? order by 1 desc");
49         pstmt.setLong(1, lCompanyID);
50         rs = pstmt.executeQuery();
51         rs.next();
52         procDate = rs.getDate(1);
53       }
54       catch(SQLException e) {
55         e.printStackTrace(System.err);
56       }
57       finally {
58         if(rs != null) {
59           try {
60             rs.close();
61           }
62           catch(SQLException ignore) {}
63         }
64         if(pstmt != null) {
65           try {
66             pstmt.close();
67           }
68           catch(SQLException ignore) {}
69         }
70         if(da != null) {
71           da.disconnect();
72         }
73       }
74   
75       return procDate;
76     }
77   }
78   
79