Java Timestamp Parse parseTimeStamp(String timeStampString)

Here you can find the source of parseTimeStamp(String timeStampString)

Description

parse timestamp.

License

Open Source License

Parameter

Parameter Description
timeStampString the time stamp string

Return

the timestamp

Declaration

public static Timestamp parseTimeStamp(String timeStampString) 

Method Source Code

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

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

import java.util.Date;

public class Main {
    /**// www.ja va 2  s .  co  m
     * parse timestamp.
     *
     * @param timeStampString the time stamp string
     * @return the timestamp
     */
    public static Timestamp parseTimeStamp(String timeStampString) {
        Timestamp result = null;
        try {
            SimpleDateFormat format = new SimpleDateFormat(
                    "yyyy-MM-dd HH:mm:ss.S");
            Date parsed = format.parse(timeStampString);
            result = new Timestamp(parsed.getTime());
        } catch (ParseException pe) {
            System.out.println("ERROR: Cannot parse \"" + timeStampString
                    + "\"");
        } catch (Exception x) {
            x.printStackTrace();
        }
        return result;
    }
}

Related

  1. parseTimeStamp(String timeStamp)
  2. parseTimestamp(String timestamp)
  3. parseTimestamp(String timestamp)
  4. parseTimeStamp(String timeStamp)
  5. parseTimestamp(String timestamp, String dateFormat, Locale locale)
  6. parseTimestamp(String value)
  7. parseTimestamp(String value)
  8. parseTimestamp2Long(String datestring, String datepattern, TimeZone timeZone)
  9. parseTimestampDirectory(final String stamp)