0

I think the problem is in my custom Adapter when I setText datePage

I have this format lWed Jun 15 14:38:00 CEST 2016

I want 15/06/2016

public class MyAdapter extends ArrayAdapter <Page> {

    Context context;
    int ressource;
    TextView tvTitreList;
    TextView tvDateList;
    TextView tvTagList;
    Page page ;
public MyAdapter(Context context,  ArrayList <Page> data ) {
        super(context, 0, data);
    }
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = LayoutInflater.from(getContext()).inflate(R.layout.activity_list_perso, parent, false);
        }
        tvTitreList = (TextView) convertView.findViewById(R.id.tvTitre);
        tvDateList = (TextView) convertView.findViewById(R.id.tvDate);
        tvTagList  = (TextView) convertView.findViewById(R.id.tvTag);

This part of my class MyAdapter

        SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
        tvTitreList.setText(getItem(position).titrePage);
        tvDateList.setText(getItem(position).datePage.toString()); // <==dateFormat? How I put in ?
        tvTagList.setText(getItem(position).texteTag); 
Valentin
  • 25
  • 7

1 Answers1

1

Format the date using SimpleDateFormat:

SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
String formattedDate = dateFormat.format(datePage);
Jay
  • 324
  • 2
  • 14
  • thanks but I can't put String formattedDate in my constructor Page, because there is String title Date datePage and texteTAg listPageTagArray.add(new Page(idPage,titrePage,datePage,tagPage)); – Valentin Jun 16 '16 at 21:26