0

I am trying to convert a String in ISO timestamp format to a SimpleDateFormat like so:

public static void convertDate () {
  String timestamp = DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.format(new Date());
  DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZZ");
  Date date = (Date)formatter.parse(timestamp);  
}

The above code throws the following exception:

java.text.ParseException: Unparseable date:
Alexis Pigeon
  • 7,423
  • 11
  • 39
  • 44
sony
  • 1,557
  • 10
  • 36
  • 50

1 Answers1

1

If you are parsing date's from XML in ISO 8601 format you can use the JAXB parser.

Check this post for an example

Community
  • 1
  • 1
nsfyn55
  • 14,875
  • 8
  • 50
  • 77