title: how to convert GMT offset value to +/- HH:MM
body: <pre><code>TimeZone timeZone = TimeZone.getTimeZone("Asia/Calcutta");
  
      int offset1 = timeZone.getRawOffset();
      System.out.println("offset = "+ offset);
  
      int offsetHrs = offset / 1000 / 60 / 60;
      int offsetMins = offset / 1000 / 60 % 60;
  
      System.out.println("offsetHrs="+ offsetHrs);
      System.out.println("offsetMins="+ offsetMins);
  
  
      GMTOffset = offsetHrs + ":" + offsetMins;
      System.out.println("GMTOffset = " + utzOffset);
  </code></pre>
  
  <p>The out put will be </p>
  
  <blockquote>
    <p>offset = 19800000</p>
    
    <p>offsetHrs=5</p>
    
    <p>offsetMins=30</p>
    
    <p>GMT offset = 5:30</p>
  </blockquote>
  
  <p>i am using this offset value in ms sql server to convert the time zone.
  sql server will takes the below format</p>
  
  <pre><code>(+/-)HH:MM
  </code></pre>
  
  <p>my result is 5:30 but it's giving an invalid timezone error 
  it should be +5:30 .</p>
  
  <p>in another case </p>
  
  <blockquote>
    <p>TimeZone timeZone = TimeZone.getTimeZone("Etc/GMT");</p>
    
    <p>in this case offset will be "0"</p>
    
    <p>but ms sql takes only +00:00 or -00:00 (+/- sign must)</p>
  </blockquote>
  
  <p>can any one help me how to format the offset in  <strong>(+/-)HH:MM</strong>  format. </p>