|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Member
Iscritto dal: Oct 2007
Messaggi: 33
|
[Java][SimpleDateFormat ]
salve sto provando ad utilizzare questo metodo per convertire la data che do in input al metodo "wed Mar 05 10:02.02 CET 2008" per trasformarla in dd/MM/yyyy
ma viene sempre sollevata l' eccezione .MI dice Unparseable date:... //passo al metodo dateOld ="wed Mar 05 10:02.02 CET 2008" sapreste aiutarmi??!! grazie public String formatData(String dateOld) { SimpleDateFormat dateStandard=null ; try { dateStandard = new SimpleDateFormat("EEE MMM dd HH:mm:ss 'CET' yyyy", Locale.ITALIAN).parse(dateOld); System.out.printl("DATESTANDARD"+dateStandard); } catch (ParseException e) { System.out.println("errore"); e.printStackTrace(); } String dateFormatted = new SimpleDateFormat("dd/MM/yyyy").format(dateStandard); return dateFormatted; } |
|
|
|
|
|
#2 |
|
Senior Member
Iscritto dal: Nov 2005
Città: TO
Messaggi: 5206
|
Così è corretto:
Codice:
DateFormat df = new SimpleDateFormat ("EEE MMM dd HH:mm:ss Z yyyy", Locale.ENGLISH);
Date d = df.parse ("wed Mar 05 10:02:02 CET 2008");
__________________
Andrea, SCJP 5 (91%) - SCWCD 5 (94%) |
|
|
|
|
|
#3 |
|
Member
Iscritto dal: Oct 2007
Messaggi: 33
|
grazie mille funziona!!!!
|
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 05:56.



















