title: how to start timer on a specific time in android
body: <p>I have a question. I want to start the timer on a specific time. i.e., I have a time say, 05:10:02. then the timer shall start from 05:10:02.
  Eg, 05:10:02, 05:10:03, 05:10:04 and so on.</p>
  
  <p>when I open the activity, it should fetch the current time and the timer shall start the described above in the question.</p>
  
  <p>I have the following code.</p>
  
  <pre><code>    SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
      sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
  
      inputString = str;  //05:10:02
  
  
      try {
          date = sdf.parse(inputString);
  
          Log.i("Test", "in milliseconds: " + date.getTime());  
      } catch (ParseException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  
      if(mStartTimeGlobal== 0L) {
          mStartTimeGlobal = date.getTime();
          mHandlerGlobal.removeCallbacks(mUpdateTimeTaskGlobal); 
          mHandlerGlobal.postDelayed(mUpdateTimeTaskGlobal, 100);
      }
  
  
  
       private Runnable mUpdateTimeTaskGlobal = new Runnable(){
  
      public void run() {
  
          //DecimalFormat df = new DecimalFormat("##.####");
  
          final long start = mStartTimeGlobal;
          long millis = date.getTime();
  
          int seconds = (int) (millis / 1000);
             int minutes = seconds / 60;
             seconds = seconds % 60;
             int hours = seconds/3600;
  
             String timer = String.format("%02d", hours) + ":" + String.format("%02d", minutes) + ":" + String.format("%02d", seconds);
  
             ///mTotalTimeTakenGlobal = timer;
  
             txt_start_timer.setText(timer);                                                                         
             mHandlerGlobal.postDelayed(this, 200);               
  
       }    
   };
  </code></pre>