DateToUnixTimestamp

Convert a date to a unix timestamp using daylight savings.

long GetUnixdate(java.util.Date dt) {
        long unixtimestamp;
        int hour;
        int min;
        int sec;
        long days; // days difference
        long secinday;
        long MsInDay;

        Calendar calendar = Calendar.getInstance();

        calendar.setTime(dt);
        hour = calendar.get(Calendar.HOUR_OF_DAY);
        min = calendar.get(Calendar.MINUTE);
        sec = calendar.get(Calendar.SECOND);

        secinday = 86400;
        MsInDay = secinday * 1000;
        days = calendar.getTimeInMillis() / MsInDay;

        unixtimestamp = (days * secinday) + (hour * 3600) + (min * 60) + sec;

        return unixtimestamp;
    }