Advertisement
Advertisement
| 05.07.2008 at 06:08PM PDT, ID: 23384759 | Points: 500 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: |
Util.java
public static int getCompareResult2(String date) throws ParseException {
DateFormat df = new SimpleDateFormat("dd/MM/yyyy", Locale.getDefault());
df.setLenient ( false );
DateFormat df1 = new SimpleDateFormat("EEE MMM dd kk:mm:ss zzz yyy", Locale.getDefault());
df1.setLenient ( false );
Date d1= df.parse(date);
Date now = df1.parse(new Date().toString());
Calendar today = Calendar.getInstance(Locale.getDefault());
today.setTime(now);
Calendar compare = Calendar.getInstance(Locale.getDefault());
compare.setTime(d1);
compare.set(Calendar.HOUR_OF_DAY, 0);
compare.set(Calendar.MINUTE, 0);
compare.set(Calendar.SECOND, 0);
compare.set(Calendar.MILLISECOND, 0);
today.set(Calendar.HOUR_OF_DAY, 0);
today.set(Calendar.MINUTE, 0);
today.set(Calendar.SECOND, 0);
today.set(Calendar.MILLISECOND, 0);
if (today.equals(compare)) {
return 0;
} else if(today.before(compare)) {
return -1;
} else {
return 1;
}
}
|
| Microsoft |
| Apple |
| Internet |
| Gamers |
| Digital Living |
| Virus & Spyware |
| Hardware |
| Software |
| ITPro |
| Developer |
| Storage |
| OS |
| Database |
| Security |
| Programming |
| Web Development |
| Networking |
| Other |
| Community Support |
| 05.07.2008 at 09:52PM PDT, ID: 21522404 |
| 05.07.2008 at 11:30PM PDT, ID: 21522683 |
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: |
Util.java
note:- this is the one you given for me get the values > than to todays value
public static int getCompareResult2(String date) throws ParseException {
DateFormat df = new SimpleDateFormat("dd/MM/yyyy", Locale.getDefault());
df.setLenient ( false );
DateFormat df1 = new SimpleDateFormat("EEE MMM dd kk:mm:ss zzz yyy", Locale.getDefault());
df1.setLenient ( false );
Date d1= df.parse(date);
Date now = df1.parse(new Date().toString());
Calendar today = Calendar.getInstance(Locale.getDefault());
today.setTime(now);
Calendar compare = Calendar.getInstance(Locale.getDefault());
compare.setTime(d1);
compare.set(Calendar.HOUR_OF_DAY, 0);
compare.set(Calendar.MINUTE, 0);
compare.set(Calendar.SECOND, 0);
compare.set(Calendar.MILLISECOND, 0);
today.set(Calendar.HOUR_OF_DAY, 0);
today.set(Calendar.MINUTE, 0);
today.set(Calendar.SECOND, 0);
today.set(Calendar.MILLISECOND, 0);
if (today.equals(compare)) {
return 0;
} else if(today.before(compare)) {
return -1;
} else {
return 1;
}
}
}
|
| 05.07.2008 at 11:35PM PDT, ID: 21522699 |
| 05.07.2008 at 11:48PM PDT, ID: 21522749 |
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: |
My booking.jsp
<%@page import="java.util.*"%>
<%@page import="eform.util.Util"%>
<%@page import="java.util.Date"%>
<%@page import="java.sql.*"%>
<%@page import="java.sql.Statement"%>
<%@page import="javax.sql.DataSource"%>
<%@page import="javax.naming.*"%>
<%@page import="eform.beans.*"%>
<%@page import="java.util.Calendar"%>
<%@page import="java.util.Date"%>
<%@page import="java.text.*"%>
<%@page import="java.text.DateFormat"%>
<%@page import="java.text.ParseException"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.util.Calendar"%>
<%java.util.Properties parms = new java.util.Properties();
parms.setProperty(Context.INITIAL_CONTEXT_FACTORY,"com.ibm.websphere.naming.WsnInitialContextFactory");
Context ctx = new javax.naming.InitialContext(parms);
DataSource ds = (javax.sql.DataSource) ctx.lookup("jdbc/STAFFDBS");
Connection con = ds.getConnection();
Statement stmt = con.createStatement();
//String sql = "select date,purpose,status,rid from room_booking where DATE(date) > DATE(CURRENT TIMESTAMP)";
//String sql = "select a.date,b.time,b.rbid from time_slot from room_booking a,time_slot b where a.rbid = b.rbid ";
//String sql = "select a.date,b.name,a.purpose,a.status,a.emid,c.time from room_booking a, room b, time_slot c where a.rid = where a.rid = b.rid and a.rbid = c.rbid
and status = 'Taken' and orderby date desc";
String sql = "select a.date,b.name,a.purpose,a.status,a.emid,c.time from room_booking a, room b, time_slot c where a.rid = b.rid and a.rbid=c.rbid and status =
'Taken'";
ResultSet rs = stmt.executeQuery(sql);
String date;
String name;
String purpose;
String status;
String emid;
//int rid;
String time;
Vector records = new Vector();
while (rs.next()){
date = rs.getString("date");
name = rs.getString("name");
purpose = rs.getString("purpose");
status = rs.getString("status");
emid = rs.getString("emid");
//rid = rs.getInt("rid");
time = rs.getString("time");
try{
if(eform.util.Util.getCompareResult1(date) > 0 ){
JoRoomBookingBean bean = new JoRoomBookingBean();
bean.setDate(date);
bean.setName(name);
bean.setPurpose(purpose);
bean.setStatus(status);
bean.setEmid(emid);
bean.setTime(time);
records.addElement(bean);
}
}catch(Exception e){
System.out.println("An exception occured :"+e.getMessage());
e.printStackTrace();
}
//System.out.println("Joshline test here");
}
%>
<head>
<title>ROOM BOOKING LIST</title>
</head>
<body>
<table>
<tr bgcolor="CCFFFCC">
<td>DATE</td>
<td>NAME</td>
<td>PURPOSE</td>
<td>STATUS</td>
<td>EMID</td>
<td>TIME</td>
</tr>
<%for (int i = 0; i < records.size(); i++) {
JoRoomBookingBean bean = (JoRoomBookingBean) records.elementAt(i);%>
<tr bgcolor="FFFCCCC">
<td><%=bean.getDate()%></td>
<td><%=bean.getName()%></td>
<td><%=bean.getPurpose()%></td>
<td><%=bean.getStatus()%></td>
<td><%=bean.getEmid()%></td>
<td><%=bean.getTime()%></td>
</tr>
<%}%>
</table>
Total Records:
<%=records.size()%>
</body>
</html>
|
| 05.07.2008 at 11:57PM PDT, ID: 21522790 |
1: 2: 3: 4: 5: 6: |
>> String sql = "select a.date,b.name,a.purpose,a.status,a.emid,c.time from room_booking a, room b, time_slot c where a.rid = b.rid and a.rbid=c.rbid and status = 'Taken'"; >> to String sql = "select a.date,b.name,a.purpose,a.status,a.emid,c.time from room_booking a, room b, time_slot c where a.rid = b.rid and a.rbid=c.rbid and status = 'Taken' order by 1"; |
| 05.08.2008 at 12:09AM PDT, ID: 21522826 |
| 05.08.2008 at 12:14AM PDT, ID: 21522851 |
| 05.08.2008 at 12:17AM PDT, ID: 21522862 |
| 05.08.2008 at 12:18AM PDT, ID: 21522872 |
| 05.08.2008 at 12:22AM PDT, ID: 21522897 |
| 05.08.2008 at 12:28AM PDT, ID: 21522913 |
1: |
String sql = "select TO_DATE(a.date, 'DD/MM/YYYY'),b.name,a.purpose,a.status,a.emid,c.time from room_booking a, room b, time_slot c where a.rid = b.rid and a.rbid=c.rbid and status = 'Taken' order by 1"; |
| 05.08.2008 at 12:38AM PDT, ID: 21522952 |
| 05.08.2008 at 12:49AM PDT, ID: 21523007 |
| 05.08.2008 at 12:53AM PDT, ID: 21523016 |
1: 2: 3: |
String sql = "select DATE(a.date),b.name,a.purpose,a.status,a.emid,c.time from room_booking a, room b, time_slot c where a.rid = b.rid and a.rbid=c.rbid and status = 'Taken' order by 1"; |
| 05.08.2008 at 12:55AM PDT, ID: 21523020 |
| 05.08.2008 at 12:58AM PDT, ID: 21523031 |
| 05.08.2008 at 01:04AM PDT, ID: 21523042 |
| 05.08.2008 at 01:16AM PDT, ID: 21523088 |
| 05.08.2008 at 01:40AM PDT, ID: 21523194 |
| 05.08.2008 at 01:49AM PDT, ID: 21523228 |
1: |
String sql = "select TO_DATE(CONCAT (a.date, ' 00:00:00')),b.name,a.purpose,a.status,a.emid,c.time from room_booking a, room b, time_slot c where a.rid = b.rid and a.rbid=c.rbid and status = 'Taken' order by 1"; |
| 05.08.2008 at 02:01AM PDT, ID: 21523264 |