Bonjour à tous
Alors voila j'ai une chaine qui contient une date de la forme yyyy-MM-dd hh:mm:ss. Je veux convertir ce String en Date, voici ce que je fais :
Ce code est dans la méthode init(), c'est pour une applet.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 ParsePosition pPos = new ParsePosition(0); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); try { valDateXSecond[0] = new Second(dateFormat.parse("2008-10-01 00:40:12",pPos)); catch (NullPointerException e) { System.out.println(e.getMessage()); e.printStackTrace(); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); }
Lorsque j'éxécute mon applet j'ai l'exception suivante :
Je ne comprend pas où est le problème ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 Wed Oct 01 00:40:12 CEST 2008 NULL pointer null java.lang.NullPointerException at java.util.Calendar.setTime(Unknown Source) at org.jfree.data.time.Second.<init>(Second.java:157) at org.jfree.data.time.Second.<init>(Second.java:146) at AppletGraph.init(AppletGraph.java:88) at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source) at java.lang.Thread.run(Unknown Source) java.lang.NullPointerException at AppletGraph.init(AppletGraph.java:114) at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Exception : java.lang.NullPointerException
Le system.out m'affiche la date correcte .
Merci d'avance pour vos réponse.
A+
Philobedo
Partager