Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

Setting a TimePicker to 24-hour format

$
0
0

I've searched the internet and so far there is no solution that is working. I'm trying to SHOW the time in 24 hour format. When the user selects the control, it currently presents iOS in 24 hour format, Android is still the clock where you must select AM/PM. That is fine. After the user selects the time, it always shows in AM/Pm

Here's what I've tried:

Xamarin - currently there is nothing available for cross-platform

iOS -

var timer = (UIDatePicker)Control.InputView;
timer.Locale = new Foundation.NSLocale("no_nb");

Android -

protected override void OnElementChanged(ElementChangedEventArgs<TimePicker> e)
      {
            base.OnElementChanged(e);
          Control.TextLocale = new Java.Util.Locale("es");
      }

I have one found one thing that works for Android, however it requires I manually set Control.Text to the "HH:mm" format, which ended up being unreliable (would only work on 2 of 3 TimePickers).

Is there any consistent solution for showing 24-hour format for a TimePicker?


Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>