Here you can find the source of formatDateToLong(String strDate, String formatstr)
public static long formatDateToLong(String strDate, String formatstr)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static long formatDateToLong(String strDate, String formatstr) { if (strDate == null || "".equals(strDate.trim()) || "0".equals(strDate)) { return 0; }/*from w w w .j av a 2s . c o m*/ try { SimpleDateFormat sfarmat = new SimpleDateFormat(formatstr); Date date = sfarmat.parse(strDate); return date.getTime() / 1000; } catch (Exception e) { return 0; } } }