Go from Milliseconds to Java Server Faces Hours?

0

Good day for the next query, I have a Long variable to which I assign the subtraction of two Datetime, The variable difference stores me the result in Milliseconds but I need them in hours to save them in my column of type Float and not save me this -8.5322904E7 how to modify this method in advance grateful.

 public void botonTerminarTiempo() {

    tiempos.setFechaHoraFinal(fechaActual);
    tiemposFacade.edit(tiempos);        
    Long diferencia = (tiempos.getFechaHoraInicio().getTime() - tiempos.getFechaHoraFinal().getTime());        
    tiempos.setTotalHoraHombre(diferencia.floatValue());
    tiemposFacade.edit(tiempos);
    fechaActual = new Date();
    laborSeleccionada = new Labor();
    lineaSeleccionada = new Linea();
    operarioSeleccionado = new Operarios();
    ordentrabajo = new Ordentrabajo();
    tiempos = new Tiempos();
}
    
asked by Alexander Gil Tafur 08.09.2017 в 17:32
source

1 answer

1

You can use the class TimeUnit like this:

long hours = TimeUnit.MILLISECONDS.toHours(milliseconds);
    
answered by 08.09.2017 / 21:03
source