Java Timestamp Parse str2Timestamp(String str)

Here you can find the source of str2Timestamp(String str)

Description

str Timestamp

License

Apache License

Declaration

public static Timestamp str2Timestamp(String str) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.sql.Timestamp;

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

import java.util.Date;

public class Main {
    public static final SimpleDateFormat date_sdf = new SimpleDateFormat("yyyy-MM-dd");

    public static Timestamp str2Timestamp(String str) {
        Date date = str2Date(str, date_sdf);
        return new Timestamp(date.getTime());
    }/*w w  w .  ja  v a  2s. c  o m*/

    public static Date str2Date(String str, SimpleDateFormat sdf) {
        if (null == str || "".equals(str)) {
            return null;
        }
        Date date = null;
        try {
            date = sdf.parse(str);
            return date;
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return null;
    }
}

Related

  1. parseTimestamp(String value)
  2. parseTimestamp2Long(String datestring, String datepattern, TimeZone timeZone)
  3. parseTimestampDirectory(final String stamp)
  4. parseTimestampToString(Timestamp stamp, String dateFormat)
  5. parseToDate(String timestamp, String pattern)
  6. String2Timestamp(String date)
  7. String2Timestamp(String s, String fmt)
  8. string2Timestamp(String strDateTime, String pattern)
  9. String2Timestamp(String strInputDate)