I have a DAO (Data Access Object) to create a history. What I'm looking for is to create a history, subtract it and put that value in a variable.
However, I get nullpointerexception. Is there a problem with my code?
public boolean crearHistorial2(Equipo equipo, Usuario usuario, Integer kilo, String ubi, Integer kilore) {
Historial historial = new Historial();
historial.setEquipo(equipo);
historial.setUbicacion(ubi);
historial.setUsuario(usuario);
historial.setKilometrost(kilo);
int valor1;
valor1= Integer.parseInt(equipo.getKilometrost());
historial.setKilometros(kilo - valor1);
historial.setFecha(new Date());
return jpam.persistirEntidad(historial);
}
The error is thrown into the subtraction and I want the value of that subtraction to have the kilometers attribute.