I need to add or subtract the time difference between dates,
If the ESTADOLINEA
is 1 add, and if the ESTADOLINEA
is 2, subtract the time.
This is the SQL table:
My idea is to loop through the records
This is my code:
private void fisico(ResultSet rs) {
try {
while (rs.next()) {
if (rs.getRow() != 0) {
//si es 2 la maquina esta parada, si NO la maquina esta MARCHA
if (rs.getInt(2) == 2) {
System.out.println(rs.getInt(1) + " Maquina parada " + rs.getInt(2));
fechaInicio = String.valueOf(rs.getTimestamp(4));
} else {
System.out.println(rs.getInt(1) + " Maquina en marcha " + rs.getInt(2));
}
} else {
}
}
} catch (SQLException ex) {
System.err.println("" + ex);
}
}