2012-12-21 2 views
2

Pourquoi ai-je reçu cette exception?ParseException: date indisponible

Voici ma chaîne de format:

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

Voici la chaîne que je veux formater:

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

Mais je reçois l'exception suivante:

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) 

Répondre

4

parce que Z et non -0500 attend -05:00 si la date doit être 2012-12-29T23:59:00-0500.

Vous devez vous débarrasser de cette dernière :

0

analyseur SimpleDateFormat = nouveau SimpleDateFormat ("aaaa-MM-jj'H'HH: mm: ssz");

Essayez z au lieu de Z.

+0

Pour que le fuseau horaire devra être 'GMT-05: 00 ' –

Questions connexes