Domanda

Sto usando questa parte del codice nella mia app:

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss'Z'");
Date qdate = new GregorianCalendar(0,0,0).getTime();
try {
    qdate = sdf.parse(dt);
} catch (ParseException e) {
    e.printStackTrace();
}
.

Ma Eclipse getta un errore che dice:

Tipo di eccezione non gestito ParseException

Qual è il problema qui? Hai bisogno di me per postare l'intero codice? Thnx in anticipo!

È stato utile?

Soluzione

Vedi sotto il codice

        String date = "Sat, 23 Jun 2012 00:00:00 +0000";
        try {
            SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z");
            SimpleDateFormat df2 = new SimpleDateFormat("dd/MM/yy");
            date = df2.format(date));
        } catch (java.text.ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
.

Altri suggerimenti

Calendar c = Calendar.getInstance();

SimpleDateFormat df = new SimpleDateFormat("DD-MM-YYYY");

String Currentdatestr = df.format(c.getTime());

//get current date in String

Date date = df.parse(Currentdatestr);

//String to parse Date Format
.
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top