SimplicityApks / ReminderDatePicker

A Google Keep-like Date and Time Picker for reminders
Apache License 2.0
74 stars 26 forks source link

How do I set a 24hours mode? #9

Closed chrisonline closed 9 years ago

chrisonline commented 9 years ago

I want to set either a flag or via a method the 24hour mode. How can this be done?

I have seen in the source code it uses the system setting, but it would be useful to override this. How can this be done?

SimplicityApks commented 9 years ago

Hi, I had a look at it and made some small changes to allow you to set the time format used in TimeSpinner. This should give you all the control you need, as you can let it use your own format passing a SimpleDateFormat to setTimeFormat(). (Note only time will be affected for now, let me know if you need to control date format in DateSpinner as well, that would require a bit more work and testing). As for your specific request, I'd suggest doing it as in this issue on here. They typecast the DateFormat (returned by getDateFormat() ) to a SimpleDateFormat (which seems to work funnily) and then swap 'h's with 'H's. Though not tested, this should work in your case, reopen this issue if it doesn't ;)

chrisonline commented 9 years ago

Thanks for this new method, but it does not work inside the time selection. If I set a SimpleDateFormat for 24 hour, for example HH:mm, it displays in the dropdown 21:00 (correct) but the time popup selection is still 12 hour mode.

SimplicityApks commented 9 years ago

Sorry that you had to wait a few days, I was quite busy... Thanks for reporting, I'll have a look at it tomorrow!

SimplicityApks commented 9 years ago

Ok I finally had time to test this and found out that it didn't really use the 12 hours format in the first place, even if set by the system (my thinking was to do that in the strings so every language could have its own time format, but that didn't work so well I guess). Anyway, there should be no changes required in your code just rebuild it with the newest maven release, which I'll post in a minute!