This discussion is archived
1 Reply Latest reply: Nov 25, 2012 9:29 AM by 975668 RSS

sum hours

975668 Newbie
Currently Being Moderated
Good afternon,

I have a counter that returns the time in this format 00:00:00.
I need to add the previous number plus the number rescente. how to do this?

Total = 00:00:00 + 00:00:00;
  • 1. Re: sum hours
    975668 Newbie
    Currently Being Moderated
    I sorry!
    I solved this question.

    Totaltempo1 = lb_total_cons.getText().split(":");
    Totaltempo2 = lbTempoVer.getText().split(":");

    int horasfinal = Integer.parseInt(Totaltempo1[0])+ Integer.parseInt(Totaltempo2[0]);
    long minutosfinal = (Long.parseLong(Totaltempo1[1])+Long.parseLong(Totaltempo2[1]))%60;
    long segundosfinal = (Long.parseLong(Totaltempo1[2])+Long.parseLong(Totaltempo2[2]))%60;

    lb_total_cons.setText(DuasCasas.format(horasfinal)+":"+DuasCasas.format(minutosfinal)+":"+DuasCasas.format(segundosfinal));

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points