how to get date from milliseconds in android

后端 未结 7 1531
情话喂你
情话喂你 2021-01-17 16:32

I have time in milliseconds, now I want to separate time and date from these milliseconds.

how

7条回答
  •  余生分开走
    2021-01-17 17:09

    This function will give you a String date from milliseconds

    public static String getFormattedDateFromTimestamp(long timestampInMilliSeconds)
    {
        Date date = new Date(); 
        date.setTime(timestampInMilliSeconds);
        String formattedDate=new SimpleDateFormat("MMM d, yyyy").format(date);
        return formattedDate;
    
    }
    

提交回复
热议问题