0

My app needs to display several textview containing a specific hour.

Let's suppose I have those ones under the 24hours format. Is it possible to keep this format or to convert it to the 12hours format + am or pm according to the Locale of the phone?

I should have put everything in the 24 hours format but it's not user friendly at all. It is also important to note that for some countries like Japan, noon is 12:00 a.m. instead of 12:00 p.m. . Thats why it would be too complicated to manage that manually.

this:

java.text.DateFormat dateFormat=android.text.format.DateFormat.getDateFormat(getContext());
String s = dateFormat.format(date);

is saddly not working. Thanks in advance.

Virthuss
  • 3,142
  • 1
  • 21
  • 39
  • Did you see this? http://stackoverflow.com/questions/6981505/how-to-get-user-selected-date-format-in-android – Eric B. Jan 06 '16 at 06:58
  • Yes but it doesnt help. I have a string containing my date as a 24hours format (likle "13" ). I need to keep it as it is if I'm using a 24hours format or change it to he 12hours format and adding am or pm according to the Locale – Virthuss Jan 06 '16 at 07:00
  • This method would work fine, because if the user has set their format to 24hours, even if you format your date it wont make a difference. – Eric B. Jan 06 '16 at 07:02
  • Yes but how do I deal with the additionnal "pm" or "am"? Once again for some countries am and pm are not used on the same way for midnight and noon\ – Virthuss Jan 06 '16 at 07:07
  • can you share your date string format/value. – Bharatesh Jan 06 '16 at 07:12
  • I have a string containing the hour to the 24hours format. As an example for 1AM I have "13" – Virthuss Jan 06 '16 at 07:14

0 Answers0