Java Timestamp Format stringConvertToTimestamp(String value, String format)

Here you can find the source of stringConvertToTimestamp(String value, String format)

Description

string Convert To Timestamp

License

Open Source License

Declaration

public static final int stringConvertToTimestamp(String value, String format) 

Method Source Code


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

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {

    public static final int stringConvertToTimestamp(String value, String format) {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format);
        Date date = null;//from  ww  w. j  a v a2 s.c om
        try {
            date = simpleDateFormat.parse(value);
        } catch (ParseException e) {

        }
        return (int) (date.getTime() / 1000);
    }
}

Related

  1. getTimestampFormat()
  2. getTimeStampFormat(Date date)
  3. getTimeStampFormat(Date date)
  4. getTimestampFormat(long time)
  5. sortedTimestampFormat(Date date)
  6. TimeStamp2Date(long timestampString, String formats)
  7. timeStamp2Date(String seconds, String format)
  8. Timestamp2DDMMYYYY(java.sql.Timestamp ts)
  9. Timestamp2HHMMSS(java.sql.Timestamp ts, int iStyle)