-2

I downloaded date information from an API which is in the format of (Java)

day month monthnumber hour:minute:second EST year

how can I format this into just

month monthnumber year
Mureinik
  • 297,002
  • 52
  • 306
  • 350
fred jones
  • 245
  • 1
  • 2
  • 10

1 Answers1

1

You could use SimpleDateFormat to first parse the string to a java.util.Date, and then format it to the format you want:

String orig = "Thu Feb 19 19:40:12 EST 2015";
SimpleDateFormat parser = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy");
Date date = parser.parse(orig);
SimpleDateFormat formatter = new SimpleDateFormat("MMM dd yyyy");
String formatted = formatter.format(date);
Mureinik
  • 297,002
  • 52
  • 306
  • 350
  • this worked perfectly thanks. I just had to change ("MMM dd YYYY") to ("MMM dd yyyy") the other way causes an error – fred jones Feb 19 '15 at 17:58