I have an array of string type which holds values from database which are in the format "2014-09-02 15:19:59.000".Array has 3600 rows .now I want to calculate one hour ago time from these values in java.How to do that. Code for selection for retrieval of values from database is:
public String[] database_Current() {
List < String > timeStr = new ArrayList < String > ();
try {
con = getConnection();
String sql = "select max(logtime) from vacuum_analog_1mins";
clstmt = con.prepareCall(sql);
clstmt.execute();
rs = clstmt.getResultSet();
while (rs.next()) {
timeStr.add(rs.getString(1).substring(11, 16));
}
} catch (Exception e) {
System.out.println("\nException in Bean in getDbTable(String code):" + e);
} finally {
closeConnection();
}
// I would return the list here, but let's convert it to an array
atime = timeStr.toArray(new String[timeStr.size()]);
return atime;
}