I have date format like "EEE, dd MMM yyyy HH:mm:ss Z", and the date is
String date = "Tue, 14 Aug 2012 07:26:33 +0000";
How to change to +0700 time zone without change the date format?
This is what I try
String sDate = null;
Date date = null;
try {
sDate = "Tue, 14 Aug 2012 07:26:33 +0000";
SimpleDateFormat curFormater = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z");
curFormater.setTimeZone(TimeZone.getTimeZone("GMT"));
try {
date = curFormater.parse(sDate);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (DropboxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
lastUpdate.setText("Last Update : " + date.toString());
but the result is Tue Aug 14 14:26:33 ICT 2012
You’re nearly there, you’ve parsed the date correctly, but you’re relying on the default
toString()instead of the format you’ve already created.Try this instead for the last line: