Guest User

Untitled

a guest
Oct 11th, 2013
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. package xfade_gnomebot;
  2.  
  3. //CODE BY XFADE48X
  4. //OSBOT.ORG
  5.  
  6. public class Timer
  7. {
  8.  
  9. private long period;
  10. private long start;
  11.  
  12. public Timer(long period)
  13. {
  14. this.period = period;
  15. start = System.currentTimeMillis();
  16. }
  17.  
  18. public long getElapsed()
  19. {
  20. return System.currentTimeMillis() - start;
  21. }
  22.  
  23. public long getRemaining()
  24. {
  25. return period - getElapsed();
  26. }
  27.  
  28. public boolean isRunning()
  29. {
  30. return getElapsed() <= period;
  31. }
  32.  
  33. public void reset()
  34. {
  35. start = System.currentTimeMillis();
  36. }
  37.  
  38. public void stop()
  39. {
  40. period = 0;
  41. }
  42.  
  43. public static String format(long milliSeconds)
  44. {
  45. long secs = milliSeconds / 1000L;
  46. return String.format("%02d:%02d:%02d", new Object[] {
  47. Long.valueOf(secs / 3600L), Long.valueOf((secs % 3600L) / 60L), Long.valueOf(secs % 60L)
  48. });
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment