Android Date Timezone Change localDateToUTC(Date dtLocal)

Here you can find the source of localDateToUTC(Date dtLocal)

Description

local Date To UTC

Declaration

public static Date localDateToUTC(Date dtLocal) 

Method Source Code

//package com.java2s;

import java.util.Date;

import java.util.TimeZone;

public class Main {
    public static Date localDateToUTC(Date dtLocal) {
        if (dtLocal == null)
            return null;
        TimeZone tz = TimeZone.getDefault();
        int currentOffsetFromUTC = tz.getRawOffset()
                + (tz.inDaylightTime(dtLocal) ? tz.getDSTSavings() : 0);
        return new Date(dtLocal.getTime() - currentOffsetFromUTC);
    }//  w  ww . j  a  v a 2  s.com
}

Related

  1. toLocalDate(Date gmtDate)