how to convert date format in android

后端 未结 6 607
梦谈多话
梦谈多话 2020-11-30 08:58

I am getting date into string in YYYY/MM/DD HH:MM:SS format.I want to change it into the mm/dd/yyyy HH:mm:ss and also it will show AM and PM how ca

6条回答
  •  孤城傲影
    2020-11-30 09:39

    Use android.text.format.Time to the conversion. You can pass the time as text and it will return you the time in desired format by using timeInstance.format("");

    you need to provide formatter.

    Refer to following: Time : http://developer.android.com/reference/android/text/format/Time.html Formatter: http://pubs.opengroup.org/onlinepubs/007908799/xsh/strftime.html

    you can use any combination of formatter string to work with it :)

提交回复
热议问题