Reputation: 593
I have an app that read a rss from a website (Tue, 17 Mar 2015 12:41:41 +0000)
. I get this format date (Tue Mar 17 12:41:41 GMT 2015)
and I want to obtain this: Tuesday 17 March
in spanish Martes, 17 Marzo
.
I'm trying differents forms, but I can't parse de date.
This is my code:
DateFormat formatter = new SimpleDateFormat("EEEE, dd MMMM yyyy kk:mm:ss Z", Locale.ENGLISH);
The porcion code where I get the data of the xml parse:
else if(name.equalsIgnoreCase("pubDate")){
noticia.setFecha(formatter.parse(""+property.getFirstChild().getNodeValue()));
Upvotes: 0
Views: 389
Reputation: 2371
The following code snippet parses the English date Tue, 17 Mar 2015 12:41:41 +0000
and outputs it in a Spanish representation Martes, 17 Marzo
try {
SimpleDateFormat sdf = new SimpleDateFormat("EEEE, dd MMMM yyyy kk:mm:ss", Locale.ENGLISH);
Date date = sdf.parse("Tue, 17 Mar 2015 12:41:41 +0000");
SimpleDateFormat sdf2 = new SimpleDateFormat("EEEE, dd MMMM", new Locale("es","ES"));
System.out.println("Date: " + sdf2.format(date));
} catch (ParseException e) {
e.printStackTrace();
}
Upvotes: 2