Question

Why am I getting this exception?

Here is my format string:

SimpleDateFormat parser = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");

Here is the string I want to format:

2012-12-29T23:59:00-05:00

But I get the following exception:

java.text.ParseException: Unparseable date: "2012-12-29T23:59:00-05:00"
    at java.text.DateFormat.parse(DateFormat.java:337)
    at objectmodels.Checkout.setDueDate(Checkout.java:72)
    at threads.AccountNotifyThread.lookupAccountInfo(AccountNotifyThread.java:220)
    at threads.AccountNotifyThread.performNotificationsForUser(AccountNotifyThread.java:65)
    at threads.AccountNotifyThread.run(AccountNotifyThread.java:42)
    at java.lang.Thread.run(Thread.java:680)
Was it helpful?

Solution

It because Z expects -0500 and not -05:00 so the date should be 2012-12-29T23:59:00-0500.

You'll have to get rid of that last :

OTHER TIPS

SimpleDateFormat parser = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz");

Try the z instead of Z.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top