Create an unix timestamp of a date object - Android java.util

Android examples for java.util:Date Timestamp

Description

Create an unix timestamp of a date object

Demo Code


//package com.java2s;

import java.util.Date;

public class Main {
    /**//from w  w  w  .j av  a2s  .  c om
     * Create an unix timestamp of a date object
     * @param date
     * @return seconds since 1970-1-1
     */
    public static Long toUnixtimeTimestamp(Date date) {
        if (date == null) {
            return null;
        }
        return date.getTime() / 1000L;
    }
}

Related Tutorials