Here you can find the source of getTimeZoneOffSetInMillisecond(String dateString)
public static long getTimeZoneOffSetInMillisecond(String dateString)
//package com.java2s; public class Main { private final static String DATE_SEPARATOR_COLON = ":"; private final static String DATE_SEPARATOR_MINUS = "-"; private final static String DATE_SEPARATOR_T = "T"; private final static String DATE_SEPARATOR_PLUS = "+"; private final static String DATE_SEPARATOR_GMT = "GMT"; public static long getTimeZoneOffSetInMillisecond(String dateString) { String timeZoneOffSetInHour = getTimeZoneOffSetInHour(dateString); if (timeZoneOffSetInHour.length() == 5) { String flag = timeZoneOffSetInHour.substring(0, 1); Integer hour = Integer.parseInt(timeZoneOffSetInHour.substring(1, 3)); Integer minute = Integer.parseInt(timeZoneOffSetInHour.substring(3, 5)); if (DATE_SEPARATOR_MINUS.equals(flag)) { hour = -hour;/* w ww . jav a2 s .c om*/ minute = -minute; } return hour * 60 * 60 * 1000 + minute * 60 * 1000; } return 0; } public static String getTimeZoneOffSetInHour(String dateString) { if (dateString != null && (dateString.contains(DATE_SEPARATOR_T) || dateString.contains(DATE_SEPARATOR_GMT))) { String postFixLen6 = dateString.substring(dateString.length() - 6, dateString.length()); String postFixLen5 = dateString.substring(dateString.length() - 5, dateString.length()); String changedPostFix = changePostFixTimeZoneFormate(postFixLen6); if (changedPostFix.length() == 5) { return changedPostFix; } else if ((postFixLen5.contains(DATE_SEPARATOR_PLUS) || postFixLen5.contains(DATE_SEPARATOR_MINUS)) && !postFixLen5.contains(DATE_SEPARATOR_COLON)) { return postFixLen5; } } return ""; } private static String changePostFixTimeZoneFormate(String dateString) { if (isEndWithTimeZoneOffSetInHourLen6(dateString)) { String postFix = dateString.substring(dateString.length() - 6, dateString.length()); postFix = postFix.replace(DATE_SEPARATOR_COLON, ""); dateString = dateString.substring(0, dateString.length() - 6) + postFix; } return dateString; } private static boolean isEndWithTimeZoneOffSetInHourLen6(String dateString) { String postFix = dateString.substring(dateString.length() - 6, dateString.length()); if (postFix.length() == 6 && (postFix.contains(DATE_SEPARATOR_PLUS) || postFix.contains(DATE_SEPARATOR_MINUS)) && postFix.contains(DATE_SEPARATOR_COLON)) { return true; } return false; } }