Here you can find the source of getTzToGmt(String dateStr, String dateFormat, String beforeTimeZone, String afterTimeZone)
public static String getTzToGmt(String dateStr, String dateFormat, String beforeTimeZone, String afterTimeZone) throws ParseException
//package com.java2s; //License from project: Open Source License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; public class Main { public static String getTzToGmt(String dateStr, String dateFormat, String beforeTimeZone, String afterTimeZone) throws ParseException { SimpleDateFormat sdfBefore = new SimpleDateFormat(dateFormat); sdfBefore.setTimeZone(TimeZone.getTimeZone(beforeTimeZone)); SimpleDateFormat sdfAfter = new SimpleDateFormat(dateFormat); sdfAfter.setTimeZone(TimeZone.getTimeZone(afterTimeZone)); Date date = stringToDate(dateStr, sdfBefore); String dateGmtEight = sdfAfter.format(date); return dateGmtEight; }/* ww w .j av a 2 s . c om*/ public static Date stringToDate(String dateStr, SimpleDateFormat dateFormat) throws ParseException { Date date = dateFormat.parse(dateStr); return date; } public static long parse(String date) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try { return sdf.parse(date).getTime(); } catch (ParseException e) { e.printStackTrace(); return 0; } } public static long parse(String date, String pattern) { SimpleDateFormat sdft = new SimpleDateFormat(pattern); try { return sdft.parse(date).getTime(); } catch (ParseException e) { e.printStackTrace(); return 0; } } }