0

I have a string came from an API call. The string is in the formate of 2021-02-12T13:48:15-05:00.

I want to convert it into java date object. I try to use Date.valueOf(..), but it throws IllegalArgumentException.

I checked the other posts, seems like I need to specific the format of my string, like new SimpleDateFormat("MM/dd/yyyy").

But, I am not sure how to format this string. Can I get some help?

Thanks

kevin
  • 309
  • 2
  • 12
  • 1
    I recommend you don’t use `Date`. That class is poorly designed and long outdated. Instead use `OffsetDateTime` from [java.time, the modern Java date and time API](https://docs.oracle.com/javase/tutorial/datetime/). – Ole V.V. Mar 03 '21 at 16:36
  • 1
    — and `SimpleDateFormat` is even worse. By all means stay away from it. – Ole V.V. Mar 03 '21 at 16:37

0 Answers0