Reputation: 585
i want ask about how i can change date format from data JSON?
example the result from JSON is : Thu, 19 Jul 2012 23:28:44 +0000 --> i put that result into string
and i want change that into : datetime with my timezone --> GMT +07:00
Upvotes: 0
Views: 1871
Reputation: 13805
You can try this
// Sat, 23 Jun 2012 00:00:00 +0000
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 HH:mm");
date = df2.format(format.parse(str));
} catch (java.text.ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
CHeck this link if it helps you
https://stackoverflow.com/a/2581073/1441666
Upvotes: 2
Reputation: 13501
Date d = new Date("Thu, 19 Jul 2012 23:28:44 +0000");
SimpleDateFormat frmt = new SimpleDateFormat ("format");
frmt.setTimeZone(zone);// you need to know the zone here..
frmt.format(d);
hope it works..
Upvotes: 1
Reputation: 1325
Try to parse date with a simpleDateFormat and change your timezone.
Upvotes: 0