1

I'm getting date time as "Wed, 22 Jul 2015 18:19:23 +0000" from twilio API. As described in doc its a RFC 2822 format but don't describe time zone. Now i want to display this date to users in EST format. How to achieve this?

This is my sample code

Date sentDateInEST = new Date(twilioMessage.getDateSentInString());
System.out.println("Server date ="+twilioMessage.getDateSentInString());
//Getting Tue, 08 Sep 2015 09:11:52 +0000

DateFormat estFormat = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss");
TimeZone.setDefault(TimeZone.getTimeZone("EST"));


System.out.println("sentDateInEST = "+estFormat.parse(estFormat.format(sentDateInEST)));
//Getting Tue Sep 08 04:11:52 EST 2015

Please help me. Thanks

srihari
  • 397
  • 2
  • 7
  • 18

1 Answers1

1

Try this pattern:

String pattern = "EEE, dd MMM yyyy HH:mm:ss Z";

(you missed the Z at the end)

Andreas
  • 2,211
  • 1
  • 18
  • 36