How to get from this line 2018-07-11T09:54:40.660 +0000 Date?

  • one
    And what is this not the time and date? Clarify the question. - Eugene Krivenja
  • Well, this is not the way to display correctly. 07-11-2018 09:54 - elik
  • one
    And in your case, time is where? London, as I understand it. Do you really need London time? Usually parsit in Date , then back to the string which is necessary. And do not forget about the time zone !!! - Eugene Krivenja
  • Now I know how to get a pattern from a datformatter, but how to get a simple date from this line? - elik
  • 3
    Well, they would have written: How to get a Date object from this line? - woesss

1 answer 1

You need SimpleDateFormat to convert the string to Date.

 SimpleDateFormat formatter = new SimpleDateFormat(StringPattern); formatter.parse(your_date_string) 

To make the desired pattern, I advise you to view this article. At the end is a table with patterns.

  • and in a pattern what pattern to set? - elik
  • That which I want to receive or in which there is a line? - elik
  • Updated the answer. Added an article, everything is painted there. - Nuclominus
  • one
    @elik, when parsing from a string - the pattern should match the input string, when formatting it into a string - the desired result - woesss
  • @woesss thank you - elik