Android Date to UTC Convert localDateToUTC(Date dtLocal)

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

Description

local Date To UTC

License

Open Source License

Declaration

public static Date localDateToUTC(Date dtLocal) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

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);
    }//from   w ww  . j  ava2s  .c  o  m
}

Related

  1. nowUTC()
  2. currentDateInUTC()
  3. getCalendarInUTC(String date)
  4. getDateInUTC(String date)