How to convert Date to a particular format in android?

后端 未结 7 1689
时光说笑
时光说笑 2020-11-27 07:06

\"Mar 10, 2016 6:30:00 PM\" This is my date and I want to convert this into \"10 Mar 2016\". Can I use SimpleDateFormat in android. I am not getting the exact pattern to con

相关标签:
7条回答
  • 2020-11-27 08:05

    You need to use SimpleDateFormat class to do the needful for you

    String date = "Your input date"
     DateFormat originalFormat = new SimpleDateFormat("<Your Input format here>", Locale.US)
     DateFormat targetFormat = new SimpleDateFormat("<Your desired format here>", Locale.US)
     Date Fdate = originalFormat.parse(date)
     formattedDate = targetFormat.format(Fdate)
    
    0 讨论(0)
提交回复
热议问题