(CRONOMETRO)Duda en resto de Hora Usando Util.Date
Publicado por Israel (13 intervenciones) el 10/02/2005 17:15:31
Obtengo la hora con
Date Hora1=new Date()
int horainicial=Hora1.getHours();
int mininicial=Hora1.getMinutes();
int seginicial=Hora1.getSeconds();
//y otro objeto date
Date Hora2=new Date()
int horafinal=Hora2.getHours();
int minfinal=Hora2.getMinutes();
int segfinal=Hora2.getSeconds();
entonces::
int Horamostrar=horafinal-horainicial;
int Minmostrar=minfinal-mininicial;;
....
...
entonces si la hora final es 15:00:00
y la inicial es 14:50:59
el resto se me va a negativos 01:-50:-59
¿COMO PUEDO HACER PARA QUE NO PASE ESTO?
Date Hora1=new Date()
int horainicial=Hora1.getHours();
int mininicial=Hora1.getMinutes();
int seginicial=Hora1.getSeconds();
//y otro objeto date
Date Hora2=new Date()
int horafinal=Hora2.getHours();
int minfinal=Hora2.getMinutes();
int segfinal=Hora2.getSeconds();
entonces::
int Horamostrar=horafinal-horainicial;
int Minmostrar=minfinal-mininicial;;
....
...
entonces si la hora final es 15:00:00
y la inicial es 14:50:59
el resto se me va a negativos 01:-50:-59
¿COMO PUEDO HACER PARA QUE NO PASE ESTO?
Valora esta pregunta


0