Android SimpleDateFormat, how to use it?

后端 未结 8 1037
清歌不尽
清歌不尽 2020-11-29 01:54

I am trying to use the Android SimpleDateFormat like this:

String _Date = \"2010-09-29 08:45:22\"
SimpleDateFormat fmt = new SimpleDateFormat(\"         


        
相关标签:
8条回答
  • 2020-11-29 02:32

    It took a lot of efforts. I did a lot of hit and trial and finally I got the solution. I had used ""MMM"" for showing month as: JAN

    0 讨论(0)
  • 2020-11-29 02:37

    Here is an easy example of SimpleDateFormat tried in Android Studio 3 and Java 9:

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd", Locale.US); 
    String strDate = sdf.format(strDate);
    

    Note: SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); shows some deprecation warning in Android Studio 3 Lint. So, add a second parameter Locale.US to specify the Localization in date formatting.

    0 讨论(0)
提交回复
热议问题