Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. private class ShowTiming extends TimerTask {
  2.  
  3. public final void run() {
  4. sec--;
  5. updateFromTimer(sec);
  6. }
  7.  
  8. protected void updateFromTimer( int remainingTimeSeconds ) {
  9. if (remainingTimeSeconds > 0) {
  10. questionForm.setTitle( category + " Questions " + formatTime ( remainingTimeSeconds ) );
  11. } else {
  12. showMark();
  13. }
  14. }
  15.  
  16. String formatTime( int timeInSeconds ) {
  17. int hr = timeInSeconds/3600;
  18. int min = (timeInSeconds - (hr*3600))/60;
  19. int sec = timeInSeconds - ((hr*3600)+ ( min*60));
  20. String hrs="",mins="",secs="";
  21.  
  22. if ( hr < 10 )
  23. hrs = "" + Integer.toString ( hr );
  24. else
  25. hrs = Integer.toString ( hr );
  26.  
  27. if ( min < 10 )
  28. mins = "0" + Integer.toString ( min );
  29. else
  30. mins = Integer.toString ( min );
  31.  
  32. if ( sec < 10 )
  33. secs = "0" + Integer.toString ( sec );
  34. else
  35. secs = Integer.toString ( sec );
  36.  
  37. return ""+ hrs +":" +mins+ ":" + secs;
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement