Java Timestamp Parse parseTimestamp(String dateString)

Here you can find the source of parseTimestamp(String dateString)

Description

Convert date string to timestamp.

License

Open Source License

Parameter

Parameter Description
dateString a parameter

Declaration

public static Timestamp parseTimestamp(String dateString) 

Method Source Code

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

import java.sql.Timestamp;
import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    /**/*from  w ww.j  ava 2s  . c  om*/
     * Convert date string to timestamp.
     * 
     * @param dateString
     * @return
     */
    public static Timestamp parseTimestamp(String dateString) {
        Timestamp timestamp = null;
        try {
            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS");
            Date parsedDate = dateFormat.parse(dateString);
            timestamp = new Timestamp(parsedDate.getTime());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return timestamp;
    }
}

Related

  1. parseTimestamp(Long time, String pattern)
  2. parseTimestamp(Object o)
  3. parseTimestamp(String d)
  4. parseTimestamp(String date)
  5. parseTimestamp(String dateStr, String format)
  6. parseTimestamp(String pattern, String dateTime)
  7. parseTimestamp(String s)
  8. parseTimestamp(String s)
  9. parseTimestamp(String sDate, String sFormat)