Here you can find the source of getTimeStamp(String dateTime)
public static String getTimeStamp(String dateTime)
//package com.java2s; //License from project: Open Source License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static String getTimeStamp(String dateTime) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-M-dd hh:mm:ss"); Date date = null;/*from ww w .j a v a2s . co m*/ try { date = sdf.parse(dateTime); } catch (ParseException e) { //ignore and print e.printStackTrace(); } Calendar calendar = Calendar.getInstance(); calendar.setTime(date); return "" + (calendar.getTimeInMillis() / 1000); } }