I get the data time - "Creation date of the item, in Unix Time ."

Such an example - 1479664016

Code in adapter:

viewHolder.date.setText(String.valueOf(myList.get(i).getTime())); 

How can you properly convert to something like this: "MM dd, yyyy hh: mma"

I found a solution , but I find it difficult how and where to insert it correctly.

  • Show incoming data and how it should be output - YuriySPb

1 answer 1

Create an object with which you can convert the unix timestamp into a text string of a specific format:

 SimpleDateFormat sdf = new SimpleDateFormat("MM dd, yyyy HH:mm"); 

Transform:

 String stringDate = sdf.format(myList.get(i).getTime()*1000L); 

Set the resulting value:

 viewHolder.date.setText(stringDate); 

The second and third lines can be combined into one.