Not able to return the method value
Hey guys,
I have a method which returns a calculated value as below
Code:
private static long getETTTime(long bugID,Connection con){
int etttime=0;
try{
String query = "select max(date_modified) from mantis_bug_history_table where bug_id= ?";
PreparedStatement pst = con.prepareStatement(query);
pst.setLong(1,bugID);
ResultSet rst = pst.executeQuery();
pst.close();
System.out.println("RST value = "+rst);
SimpleDateFormat sdf = new SimpleDateFormat("hhmm");
java.util.Date date1 = rst.getTime(query);
int datedb = Integer.parseInt(sdf.format(date1));
java.util.Date date = new java.util.Date();
int datesys = Integer.parseInt(sdf.format(date));
etttime=(datesys-datedb);
}catch(Exception e){
e.printStackTrace();
}
return etttime;
}
I am taking the date from the database and then subtracting it with the current server time. So after that i am returning the etttime which will have the difference between the number of hours. So after this i have a condition which checks for this greater than as follows. (Condition's etttime should be greater than or equal to 2 hours then it should enter)
Code:
If((a==b) && ((getETTTime(169587, con))>=0200))
{
//Statements to be executed
}
When i try to do it is giving a null pointer exception and also i am not able to retreive the etttime. And also rst.getTime(query) is returning a null value. So please help me out guys as to what to do? And also how to convert the rst returned date value into the corresponding hours. Thanks a lot in advance..
Akshay.