Here you can find the source of calculateTime(Date sendTime, String timeZoneID)
public static String calculateTime(Date sendTime, String timeZoneID)
//package com.java2s; /**/*from w ww. ja v a2 s . c o m*/ * JHylaFax - A java client for HylaFAX. * * Copyright (C) 2005 by Steffen Pingel <steffenp@gmx.de> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; public class Main { public static String calculateTime(Date sendTime, String timeZoneID) { if (sendTime == null) { return "NOW"; } else { long date = sendTime.getTime(); TimeZone tz = TimeZone.getTimeZone(timeZoneID); // tz.setStartRule(Calendar.MARCH, -1, Calendar.SUNDAY, 2*60*60*1000); // tz.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2*60*60*1000); date -= tz.getRawOffset(); if (tz.inDaylightTime(sendTime)) { date -= 3600 * 1000; } return new SimpleDateFormat("yyyyMMddHHmm").format(new Date( date)); } } }