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
Asked
Active
Viewed 1,861 times
0

ngesh
- 13,398
- 4
- 44
- 60

Frank Junior
- 575
- 1
- 9
- 19
3 Answers
2
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
-
okay thx but i have another question, "EEE, dd MMM yyyy HH:mm:ss z" , z var i get is GMT +7 , but how i can change it into GMT +9? – Frank Junior Jul 20 '12 at 07:21
1
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..

ngesh
- 13,398
- 4
- 44
- 60
0
Try to parse date with a simpleDateFormat and change your timezone.

cosmincalistru
- 1,283
- 9
- 20
-
silly me. apparently the format parsing changes the date to your time zone. nirali's answer should help you. – cosmincalistru Jul 20 '12 at 07:17