Android UTC Get nowUTCString()

Here you can find the source of nowUTCString()

Description

now UTC String

License

Open Source License

Return

- UTC Date/time

Declaration

public static String nowUTCString() 

Method Source Code

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

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;

public class Main {
    /**/*from   ww  w .  ja v a 2 s.  c  o m*/
     * @return - UTC Date/time
     */
    public static String nowUTCString() {

        Calendar calendar = Calendar.getInstance();
        TimeZone timeZone = calendar.getTimeZone();

        long currentTime = System.currentTimeMillis();
        int offsetWithUTC = timeZone.getOffset(currentTime);
        long utcTime = currentTime - offsetWithUTC;
        Date now = new Date(utcTime);
        SimpleDateFormat df = new SimpleDateFormat();
        return df.format(now);

    }
}

Related

  1. nowUTC()