Formatting a calendar date

前端 未结 5 517
不思量自难忘°
不思量自难忘° 2021-02-02 07:06

I just want the date to show up like so:

Saturday, May 26, 2012 at 10:42 PM

Here\'s my code so far:

Calendar calendar = Calendar.get         


        
5条回答
  •  北恋
    北恋 (楼主)
    2021-02-02 07:34

    Use the below to format the date as required. Refer this LINK

     Calendar calendar = Calendar.getInstance();
     lastclick.setText(getString(R.string.lastclick) + " " + String.format("%1$tA %1$tb %1$td %1$tY at %1$tI:%1$tM %1$Tp", calendar));
    

    Where %1$tA for staurday, %1$tb for May,

    and so on...

提交回复
热议问题