SimpleDateFormat.parse() ignoring timezone?

Viewed 2556

I am trying to parse date string with timezone using this code for tests:

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mmZZZZZ", Locale.US);
Calendar calendar = Calendar.getInstance();
calendar.setTime(sdf.parse("2017-07-26T06:00-06:00"));
int offset = calendar.getTimeZone().getRawOffset();

I am trying to change timezone from -06 to +09, but offset always contains 10800000.

How to parse date with timezone correctly (I need time and timezone both)?

1 Answers
Related