Here you can find the source of convertDateFormatByRawOffset(DateFormat formatter, int rawOffset, long milliSecond)
public static String convertDateFormatByRawOffset(DateFormat formatter, int rawOffset, long milliSecond)
//package com.java2s; //License from project: Open Source License import java.text.DateFormat; import java.util.Date; import java.util.TimeZone; public class Main { public static String convertDateFormatByRawOffset(DateFormat formatter, int rawOffset, long milliSecond) { TimeZone destTZ = TimeZone.getDefault(); String[] timeZoneIds = TimeZone.getAvailableIDs(rawOffset); if (timeZoneIds != null && timeZoneIds.length > 0) { destTZ = TimeZone.getTimeZone(timeZoneIds[0]); formatter.setTimeZone(destTZ); } else {//from ww w .j a v a2 s . co m formatter.setTimeZone(destTZ); } return formatter.format(new Date(milliSecond)); } }