Java String to Timestamp getTimeStamp(String dateTime)

Here you can find the source of getTimeStamp(String dateTime)

Description

get Time Stamp

License

Open Source License

Declaration

public static String getTimeStamp(String dateTime) 

Method Source Code

//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);
    }
}

Related

  1. calculateClientRequestId(String timestamp)
  2. getFileNameWithTimeStampInterposed(final String fileName)
  3. getStringToTimestamp(String string)
  4. getTimeStamp(String date)
  5. getTimestamp(String dateValue, String pattern, TimeZone timezone)
  6. getTimestamp(String pattern)
  7. getTimeStamp(String pattern, String strDate)
  8. getTimeStamp(String style, Date date)