24 hour format setting in Android

When i was developing a date time picker component for our customer, there was a request from them.
When user selects time, show 24 hour format with user setting. If user uses 12 hour format in his/her phone settings, show AM/PM selection, otherwise don't show this selection.
In Android, to get 24 hour setting from user settings, i have used following code lines to get 24 hour format of user.

Settings.System.getString(context.getContentResolver(), Settings.System.TIME_12_24);

When i was testing application on different phones, i received this value as a null on some phones.When i was researching Android SDK, there was an another method to get 24 hour format from setting.

android.text.format.DateFormat.is24HourFormat(context)

No error and i got 24 hour format setting on all test phones. What is happening? When i check DateFormat.java file from source code of Android, there is the tricky :
    
public static boolean is24HourFormat(Context context) {
    String value = Settings.System.getString(context.getContentResolver(), 
                                             Settings.System.TIME_12_24);
    if (value == null) {
        ...
        ...
is24HourFormat function also checks Settings.System.TIME_12_24 setting and if it is null, get setting from another way. So, keep using DateFormat.is24HourFormat(context) to get 24 hour format in application.

19 comments:

venkat said...

Nice blog has been shared by you. it will be really helpful to many peoples who are all working under the technology.thank you for sharing this blog.

Android Online Training

Melba henry said...

I simply want to say I’m very new to blogs and actually loved you’re blog site. Almost certainly I’m going to bookmark your blog post . You absolutely come with great well written articles. Thanks a lot for sharing your blog. Cloud Computing Training in Chennai | Selenium Training in Chennai

Mageshkumar said...

Pharmacy Management System helps the organisation to keep a track of all the information related to the pharmacies.
Android Course in Chennai

mathimathi said...

Ha Ha. Too good!! This is quite a collection. Keep Blogging!!
Ethical Hacking Course in Chennai |
Ethical Hacking Course in Chennai |
Ethical Hacking Courses

mathimathi said...

Very interesting pharmacy management software indeed.
Android Training in Chennai |
Android training |
Android Course in Chennai

thulasiram said...

This is an interesting blog that you have posted, you shares a lot of useful things about public health.
JAVA Training in Chennai |
JAVA Course in Chennai |
Best JAVA Training in Chennai

thulasiram said...

Wow!! i am very impressed with your lovely post.. I am so glad to left comment on this..This has been a so interesting read, would love to read more here
Cloud computing Training |
Cloud computing Training in Chennai |
Cloud computing courses in Chennai



radhika said...

Thanks for sharing your blog is awesome.I gathered lots of information from this blog.

AWS training in Chennai

AWS Online Training in Chennai

AWS training in Bangalore

AWS training in Hyderabad

AWS training in Coimbatore

AWS training

AWS online training

SWEETIE said...

"Undeniably imagine that which you stated. Your favorite reason seemed to be at the net the easiest factor to take note of. I say to you, I definitely get irked at the same time as people consider issues that they just do not recognize about. You controlled to hit the nail upon the highest and also defined out the entire thing with no need side effect, other people can take a signal. Will likely be again to get more. Thank you"

야한동영상
립카페
횟수 무제한 출장
스포츠마사지
바카라사이트

Anonymous said...

Mmorpg oyunları
Instagram Takipçi Satın Al
tiktok jeton hilesi
tiktok jeton hilesi
antalya saç ekimi
İNSTAGRAM TAKİPCİ SATIN AL
instagram takipçi satın al
metin2 pvp serverlar
instagram takipçi satın al

Anonymous said...

Tül perde modelleri
sms onay
mobil odeme bozdurma
Nft nasıl alinir
ankara evden eve nakliyat
trafik sigortası
Dedektör
site kurma
aşk kitapları

Anonymous said...

maltepe daikin klima servisi
kadıköy daikin klima servisi
beykoz daikin klima servisi
üsküdar daikin klima servisi
kartal toshiba klima servisi
ümraniye toshiba klima servisi
ümraniye beko klima servisi
tuzla vestel klima servisi
tuzla bosch klima servisi

kıbrıs bahis siteleri said...

Success Write content success. Thanks.
canlı poker siteleri
betpark
betturkey
deneme bonusu
canlı slot siteleri
betmatik
kralbet

sportsbet said...

Good content. You write beautiful things.
mrbahis
vbet
sportsbet
taksi
hacklink
hacklink
mrbahis
vbet
korsan taksi

Ah said...

slot siteleri
kralbet
betpark
tipobet
betmatik
kibris bahis siteleri
poker siteleri
bonus veren siteler
mobil ödeme bahis
1HQX

Anonymous said...

شركة تسليك مجاري بالقصيم
شركة تسليك مجاري بالجبيل

irem said...

başakşehir
bayrampaşa
beşiktaş
beykoz
beylikdüzü
AGENSD

sezer said...

beşiktaş
bakırköy
zeytinburnu
adapazarı
izmit
WHH

Anonymous said...

صيانة افران مكة V65Jd5MgDx

Post a Comment