Here you can find the source of getConvertDateString(Date date, TimeZone tz, String fmt)
public static String getConvertDateString(Date date, TimeZone tz, String fmt)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; public class Main { public static String getConvertDateString(Date date, TimeZone tz, String fmt) { if (date == null) return null; SimpleDateFormat format = new SimpleDateFormat(fmt); Date newDete = getConvertDate(date, tz); return format.format(newDete); }/*from ww w .ja v a 2s . com*/ /** * Convert date to specified time zone * @param date * @param tz * @return */ public static Date getConvertDate(Date date, TimeZone tz) { if (date == null) return null; int offset = tz.getRawOffset(); if (tz.inDaylightTime(date)) offset += 3600000; return new Date(date.getTime() + offset); } }