I create a calendar object from a string date I receive.
Calendar cal = Calendar.getInstance();
String date = "example Mon, 22 Oct 2012 23:58:31 GMT";
SimpleDateFormat sdf = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z");
sdf.setTimeZone (TimeZone.getTimeZone ("PST"));
try {
cal.setTime(sdf.parse(date));
} catch (ParseException e) {
e.printStackTrace();
}
System.out.println("date "+sdf.format(cal.getTime()));
This date converts and prints the gmt time to pst with no problem.
I then loop through an array of the elements object and add seconds
int offset = element.getSeconds;
cal.add(Calendar.SECOND, offset);
System.out.println("times cal offset: " + cal.getTime());
This cal now prints the server time (which is eastern time) and not the converted gmt that is printed above. Does something bypass the cal created from the string gmt date when seconds are added?
Thanks!
This because you don’t use SDF with setted GMT timezone for printing in second time.