Java String to Timestamp getTimeStampInSecond(String timeStr)

Here you can find the source of getTimeStampInSecond(String timeStr)

Description

get Time Stamp In Second

License

Open Source License

Declaration

public static long getTimeStampInSecond(String timeStr) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.text.ParseException;
import java.text.SimpleDateFormat;

public class Main {
    public static long getTimeStampInSecond(String timeStr) {
        SimpleDateFormat timeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try {/*ww w. ja  va2 s  .  c om*/
            return timeFormat.parse(timeStr).getTime() / 1000;
        } catch (ParseException e) {
            e.printStackTrace();
            return -1;
        }
    }
}

Related

  1. getTimeStamp(String pattern, String strDate)
  2. getTimeStamp(String style, Date date)
  3. getTimestamp(String timeStampStr, String logRundateIdStr)
  4. getTimestamp(String timezone, String dateTime, String pattern)
  5. getTimestampFromDateString(String date)
  6. isTimestamp(String str, boolean allowEmpty)
  7. isTimeStampValid(String timestamp)
  8. string2Timestamp(String dateString, String timezone)
  9. string2timestamp(String timeString)