Java Unix time getUnixTime(Date date)

Here you can find the source of getUnixTime(Date date)

Description

get Unix Time

License

LGPL

Declaration

public static long getUnixTime(Date date) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import java.util.Calendar;
import java.util.Date;

public class Main {
    public static long getUnixTime(Date date) {
        Calendar instance = Calendar.getInstance();
        instance.setTime(date);// w w w .j a  v  a2 s  .  c om
        long utc = Date.UTC(instance.get(Calendar.YEAR) - 1900, instance.get(Calendar.MONTH),
                instance.get(Calendar.DAY_OF_MONTH), instance.get(Calendar.HOUR_OF_DAY),
                instance.get(Calendar.MINUTE), instance.get(Calendar.SECOND));
        return utc;
    }
}

Related

  1. getUnixEpochDateTime()
  2. getUnixTimeByDate(Date date)
  3. unix2afpTime(long ut)
  4. unixDateToString(int date)
  5. unixTime()