convert timestamp into current date in android

后端 未结 10 674
滥情空心
滥情空心 2020-12-04 21:25

I have a problem in displaying the date,I am getting timestamp as 1379487711 but as per this the actual time is 9/18/2013 12:31:51 PM but it displays the time as 17-41-197

10条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-04 22:00

    I got this from here: http://www.java2s.com/Code/Android/Date-Type/CreateDatefromtimestamp.htm

    None of the above answers worked for me.

    Calendar c = Calendar.getInstance();
    c.setTimeInMillis(Integer.parseInt(tripBookedTime) * 1000L);
    Date d = c.getTime();
    SimpleDateFormat sdf = new SimpleDateFormat("MMM dd, yyyy");
    return sdf.format(d);
    

    And by the way: ("dd-MM-yyyy", cal) is not recognized by Android - "Cannot resolve method".

提交回复
热议问题