Java Date Calculate calculateOffsetFromGMT(Date date)

Here you can find the source of calculateOffsetFromGMT(Date date)

Description

Calculates a date time offset from GMT.

License

Open Source License

Parameter

Parameter Description
gmtDate the input GMT date.

Return

the local date.

Declaration

public static Long calculateOffsetFromGMT(Date date) 

Method Source Code

//package com.java2s;
/*//w ww  .  j a va2 s  . co  m
 * All GTAS code is Copyright 2016, Unisys Corporation.
 * 
 * Please see LICENSE.txt for details.
 */

import java.util.Calendar;
import java.util.Date;

public class Main {
    /**
     * Calculates a date time offset from GMT.
     * 
     * @param gmtDate
     *            the input GMT date.
     * @return the local date.
     */
    public static Long calculateOffsetFromGMT(Date date) {
        Calendar cal = Calendar.getInstance();
        /*
         * get the default time zone object and then calculate the signed offset
         * from GMT.
         */
        long offset = cal.getTimeZone().getOffset(date.getTime());
        return offset;
    }
}

Related

  1. calculateEndDate(Date startDate, int duration)
  2. calculateGestationAge(Date today, Date edd)
  3. calculateLookbackDate(int lookback)
  4. calculateMonthIn(Date date1, Date date2)
  5. calculateNextSettleDate(Date date, int addMonth)
  6. calculatePastDate(int days)
  7. calculateTime(Date date, String addpart, int num)
  8. calculateTime(Date sendTime, String timeZoneID)
  9. calculateTimestamp()