I have built a watch face that tells time in two different ways. The watch face has 12hr format for the current time zone and 24hr format for GMT. By default the watch face only displays the current time zone which means my hour hand for the GMT is really only indicating the time in the current time zone in 24hr format. How do I make the watch display multiple time zones simultaneously?
Asked
Active
Viewed 1,427 times
2 Answers
0
You can create 2 Calendar objects with different time zones and then use this objects:
Calendar germanyTime = new GregorianCalendar(TimeZone.getDefault());//your timezone
Calendar germanyTime = new GregorianCalendar(TimeZone.getTimeZone("GMT+0"));

x90
- 2,140
- 15
- 25
-
thanks for pointing me in the right direction. Where in my code should it be applied? – skeete Apr 06 '15 at 21:48
-
this code demonstrates the main idea, that you can hold 2 independent calendar objects and get time from different timezones – x90 Apr 07 '15 at 21:11
-
I understand but Im no master programmer so its kinda foreign to me. lol – skeete Apr 07 '15 at 22:01
0
I'll give you an example on how I managed to automatically get the system's time format:
// variables
boolean is24Hour = false;
DateFormat df;
Calendar cal;
// get time format
is24Hour = df.is24HourFormat(context);
...
@Override
public void onDraw(Canvas canvas, Rect bounds) {
// always get a new instance in your onDraw()
cal = Calendar.getInstance();
// get the hours
if (is24Hour) {
format = new SimpleDateFormat("H");
return Integer.valueOf(format.format(cal.getTime()));
} else {
format = new SimpleDateFormat("h");
return (Integer.valueOf(format.format(cal.getTime()));
}
}