ParseException

2 respostas
E

Preciso que retorne 2013/10/24 15:13:17

estou fazendo a seguinte rotina

String dateStr = "Thu Oct 24 15:13:17 BRST 2013";
DateFormat formatter = new SimpleDateFormat("E MMM dd HH:mm:ss Z yyyy");
Date date = (Date)formatter.parse(dateStr);
System.out.println(date);        

Calendar cal = Calendar.getInstance();
cal.setTime(date);
String formatedDate = cal.get(Calendar.DATE) + "/" + (cal.get(Calendar.MONTH) + 1) + "/" +         cal.get(Calendar.YEAR);
System.out.println("formatedDate : " + formatedDate);

porem esta dando erro no formatter :

Exception in thread main java.text.ParseException: Unparseable date: Thu Oct 24 15:13:17 BRST 2013

at java.text.DateFormat.parse(DateFormat.java:337)

at controle.Main.main(Main.java:44)

Java Result: 1

2 Respostas

pmlm

Se o que queres é a data atual nesse formato:

String formatedDate = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(new Date());
System.out.println(formatedDate);
mauricioadl
... new SimpleDateFormat("E MMM dd HH:mm:ss Z yyyy", Locale.ENGLISH);
Criado 24 de outubro de 2013
Ultima resposta 29 de out. de 2013
Respostas 2
Participantes 3