Here you can find the source of extractTimeZone(String strdate, Date thedate)
private static Date extractTimeZone(String strdate, Date thedate)
//package com.java2s; // are made available under the terms of the Eclipse Public License v1.0 import java.util.*; public class Main { private static Date extractTimeZone(String strdate, Date thedate) { // try to extract -06:00 String tzSign = strdate.substring(strdate.length() - 6, strdate.length() - 5); String tzHour = strdate.substring(strdate.length() - 5, strdate.length() - 3); String tzMin = strdate.substring(strdate.length() - 2); if (tzSign.equals("-") || tzSign.equals("+")) { int h = Integer.parseInt(tzHour); int m = Integer.parseInt(tzMin); // NOTE: this is really plus, since perspective is from GMT if (tzSign.equals("+")) { h = -1 * h;//from w w w. j a v a 2 s. co m m = -1 * m; } Calendar cal = Calendar.getInstance(); cal.setTime(thedate); cal.add(Calendar.HOUR_OF_DAY, h); cal.add(Calendar.MINUTE, m); // calculate according the used timezone cal.add(Calendar.MILLISECOND, localTimeDiff(cal.getTimeZone(), thedate)); thedate = cal.getTime(); } return thedate; } private static int localTimeDiff(TimeZone tz, Date date) { if (tz.inDaylightTime(date)) { int dstSavings = 0; if (tz.useDaylightTime()) { dstSavings = 3600000; // shortcut, JDK 1.4 allows cleaner impl } return tz.getRawOffset() + dstSavings; } return tz.getRawOffset(); } }