Here you can find the source of convertDateToServerTimeZoneDateInMilliSec(String timeZoneName, long milliSecond)
Parameter | Description |
---|---|
timeZoneName | a parameter |
milliSecond | a parameter |
public static long convertDateToServerTimeZoneDateInMilliSec(String timeZoneName, long milliSecond)
//package com.java2s; //License from project: Open Source License import java.util.Calendar; import java.util.TimeZone; public class Main { /**/* w w w . ja v a2 s . co m*/ * This will convert server date/time to specified Time zone date/time and return the date in milliSecond. * * @param timeZoneName * @param milliSecond * @return */ public static long convertDateToServerTimeZoneDateInMilliSec(String timeZoneName, long milliSecond) { if (timeZoneName != null) { TimeZone loginTimeZone = TimeZone.getTimeZone(timeZoneName); Calendar calender = Calendar.getInstance(loginTimeZone); if (milliSecond != 0) { calender.setTimeInMillis(milliSecond); } calender.add(Calendar.MILLISECOND, -(calender.getTimeZone().getRawOffset())); calender.add(Calendar.MILLISECOND, -(calender.getTimeZone().getDSTSavings())); calender.add(Calendar.MILLISECOND, TimeZone.getDefault().getRawOffset()); return calender.getTimeInMillis(); } return milliSecond; } }