Sagar Garg
Sagar Garg

Reputation: 111

Android Watch Face TextClock

I have an Android Watch Face that works for 12-hour formats. I am confused how to implement a 24-hour format based on the system preference of the phone, using TextClock or any other method.

SimpleDateFormat twelvehour = new SimpleDateFormat("h:mm a", Locale.US);
String TimeAmPmNoSec = String.format("%s", twelvehour.format(cal.getTime()));
canvas.drawText(TimeAmPmNoSec, (centerX - (timeXLength / 2.0f ), timeYOffset, timePaint);

Upvotes: 0

Views: 206

Answers (1)

Ali Naddaf
Ali Naddaf

Reputation: 19044

That setting is bridged from your phone to the watch automatically and you can get it on your watch app by calling DateFormat.is24HourFormat(context).

Upvotes: 2

Related Questions