-4

I'm new to android. I'm developing an app in which a user will get the return date of his/her books.

I can successfully retrieve the date from an external server. The problem is I am putting the date as a text view and I am getting it in the format yyyy/mm/dd. But I would like the date in Simple Format dd/mm/yyyy. How can I do that? this i have done so far.

    String returndate = in.getStringExtra(TAG_DATE_TO);
    TextView lblreturndate = (TextView) findViewById(R.id.returndate_label);

in lblreturndate i want format to be like "dd/mm/yyyy".

Thanks in Advance.

2 Answers2

1
DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
String d = formatter.format(date);
albertoqa
  • 525
  • 3
  • 11
0

You have to construct a SimpleDateFormat with this pattern:

SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy") ;
df.format(date);

For more information see SimpleDateFormat documentation

Viraj Nalawade
  • 3,137
  • 3
  • 28
  • 44
Jens
  • 67,715
  • 15
  • 98
  • 113