Here you can find the source of dateToStamp(String date)
public static String dateToStamp(String date)
//package com.java2s; //License from project: Apache License import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static String TIME_FORMAT = "yyyy-MM-dd HH:mm:ss"; public static String dateToStamp(String date) { try {//from ww w .j a v a 2 s. c om SimpleDateFormat simpleDateFormat = new SimpleDateFormat(TIME_FORMAT); Date date1 = simpleDateFormat.parse(date); long ts = date1.getTime() / 1000; return String.valueOf(ts); } catch (Exception e) { } return String.valueOf(getDateStamp() / 1000); } public static Timestamp getTime() { String day = new SimpleDateFormat(TIME_FORMAT).format(Calendar.getInstance().getTime()); return Timestamp.valueOf(day); } public static long getDateStamp() { return (long) System.currentTimeMillis() / 1000; } }