Advertisement
Guest User

Untitled

a guest
Apr 7th, 2016
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. import java.util.Calendar;
  2. import java.util.TimeZone;
  3. import javax.swing.JLabel;
  4.  
  5. public class runningTime {
  6. private int i=0;
  7. JLabel l1 = new JLabel();
  8.  
  9. public void setI(int s){
  10. i = s;
  11. }
  12. public void getS(){
  13. Thread tr = new Thread(){
  14. public void run(){
  15. try{
  16. for(;;){
  17. TimeZone tz = Calendar.getInstance().getTimeZone();
  18. Calendar c = Calendar.getInstance(tz);
  19. if(i==1){
  20. c.setTimeZone(TimeZone.getTimeZone("America/Los_Angeles"));
  21. }else if(i==2){
  22. c.setTimeZone(TimeZone.getTimeZone("America/New_York"));
  23. }else if(i==3){
  24. c.setTimeZone(TimeZone.getTimeZone("Europe/Moscow"));
  25. }else if(i==4){
  26. c.setTimeZone(TimeZone.getTimeZone("Europe/London"));
  27. }else if(i==5){
  28. c.setTimeZone(TimeZone.getTimeZone("Europe/Paris"));
  29. }else if(i==6){
  30. c.setTimeZone(TimeZone.getTimeZone("Australia/Sydney"));
  31. }else if(i==7){
  32. c.setTimeZone(TimeZone.getTimeZone("Asia/Tokyo"));
  33. }else if(i==8){
  34. c.setTimeZone(TimeZone.getTimeZone("America/Santiago"));
  35. }else if(i==9){
  36. c.setTimeZone(TimeZone.getTimeZone("Egypt"));
  37. }
  38. String hour = String.format("%02d",c.get(Calendar.HOUR_OF_DAY) );
  39. String min = String.format("%02d", c.get(Calendar.MINUTE));
  40. String sec = String.format("%02d", c.get(Calendar.SECOND));
  41. String s1 = hour +":"+min+":"+sec;
  42. l1.setText(s1);
  43. sleep(1000);
  44. }
  45. }catch(Exception e){
  46. //нуб не знает исключений, простите
  47. }
  48. }
  49. };
  50. tr.start();
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement