2

I am using this code to give me GMT time:

Time now = new Time();
now.setToNow();

The time is in GMT but I am in GMT+12. Is there a very simple way to get the time in GMT+12?

Thanks.

Ogen
  • 6,499
  • 7
  • 58
  • 124
  • You can get the current Date & Time dependant of your Android System by using `Calendar.getInstance()`. Maybe the Calendar object has what you need. – metacircle Oct 01 '13 at 10:22
  • This may help: [another question](http://stackoverflow.com/questions/6014903/getting-gmt-time-with-android) – Aycan Yaşıt Oct 01 '13 at 10:23

2 Answers2

0

Use Time(String timezone) constructor:

Time now = new Time(Time.getCurrentTimezone());
ozbek
  • 20,955
  • 5
  • 61
  • 84
0
TimeZone tz = TimeZone.getTimeZone("GMT+12:00");
    Calendar c = Calendar.getInstance(tz);
    String time = c.get(Calendar.HOUR_OF_DAY)+":"+c.get(Calendar.MINUTE)+":"+c.get(Calendar.SECOND);

    Log.e("time","is"+time);
Anchit Mittal
  • 3,412
  • 4
  • 28
  • 48