Android Date to UTC Convert nowUTC()

Here you can find the source of nowUTC()

Description

now UTC

License

Open Source License

Declaration

public static Date nowUTC() 

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 nowUTC() {
        Date dateTimeNow = new Date();
        return localDateToUTC(dateTimeNow);
    }/* w  w w  .  j av a 2 s .  co m*/

    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);
    }
}

Related

  1. localDateToUTC(Date dtLocal)
  2. currentDateInUTC()
  3. getCalendarInUTC(String date)
  4. getDateInUTC(String date)