0

I'm working on an anadroid application where an user sees the data from certain vehicles including manufacturing date so far I've got it to work by making a method that transforms a string to date, giving it a date format so it'd recognize it.

private Date ToDate(String aDate) {
    if(aDate==null) return null;
    ParsePosition pos = new ParsePosition(0);
    SimpleDateFormat simpledateformat = new SimpleDateFormat("yyyy-MM-dd");
    Date stringDate = simpledateformat.parse(aDate, pos);
    return stringDate;
}

It works fine when I add data to an arraylist, but when I want that data to be displayed it doesn't show the date in the format I gave it, it shows it like this

enter image description here

I have no idea what to do, even tried changing the date format again, but it still shows the date that way.

I must be missing something obvious, but I don't know what.

Slava Vedenin
  • 58,326
  • 13
  • 40
  • 59
nothing
  • 151
  • 2
  • 6
  • Possible duplicate of [Parse String date in (yyyy-MM-dd) format](https://stackoverflow.com/questions/18873014/parse-string-date-in-yyyy-mm-dd-format) – Ole V.V. Nov 26 '17 at 06:54
  • Any reason why in 2017 you are using the long outmoded `SimpleDateFormat` class? Judging from the number of questions about it, it is causing trouble for many. Furthermore, [`java.time`, the modern Java date and time API,](https://docs.oracle.com/javase/tutorial/datetime/) is so much nicer to work with. – Ole V.V. Nov 26 '17 at 06:56
  • The obvious thing you are missing is that a `Date` cannot have a format in it. The format is in your string, outside the date. – Ole V.V. Nov 26 '17 at 06:58

0 Answers0