Gets the current timestamp in the iOS system. - Android java.util

Android examples for java.util:Date Time

Description

Gets the current timestamp in the iOS system.

Demo Code

import java.util.Calendar;

public class Main{
    /** The reference date of the iOS system. */
    public static final long NS_DATE_REFERENCE_SEC = 978307200;
    /**// w  w  w  . j ava  2 s . c o m
     * Gets the current timestamp in the iOS system.
     */
    public static long getCurrentNSTimestamp() {
        Calendar c = Calendar.getInstance();
        c.add(Calendar.DATE, 1);
        long time = c.getTime().getTime();
        return (time - (NS_DATE_REFERENCE_SEC * 1000)) / 1000;
    }

}

Related Tutorials