Here you can find the source of DateToInteger(Date date)
public static Long DateToInteger(Date date)
//package com.java2s; //License from project: Open Source License import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class Main { public static Long DateToInteger(Date date) { SimpleDateFormat f = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.ENGLISH); String t = date.toString(); Long dateLong = null;//from w ww .j av a 2 s.c o m try { Date d = f.parse(t); dateLong = d.getTime() / 1000; } catch (ParseException e) { e.printStackTrace(); } return dateLong; } public static Date parse(String source, String format) throws ParseException { if (source == null) { return null; } DateFormat df = null; if (format != null) { df = new SimpleDateFormat(format); } else { df = DateFormat.getDateInstance(DateFormat.DEFAULT); } return df.parse(source); } public static String getTime(Date dt, String format) { SimpleDateFormat st = new SimpleDateFormat(format); return st.format(dt); } }