Java Timestamp StrToTimestamp(String timestampStr,String pattern)

Here you can find the source of StrToTimestamp(String timestampStr,String pattern)

Description

Str To Timestamp

License

Apache License

Declaration

public static Timestamp StrToTimestamp(String timestampStr,String pattern) throws ParseException 

Method Source Code


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

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

public class Main {

    public static Timestamp StrToTimestamp(String timestampStr, String pattern) throws ParseException {
        java.util.Date date = null;
        SimpleDateFormat format = new SimpleDateFormat(pattern);
        try {// ww  w  .ja  v a  2  s .c o m
            date = format.parse(timestampStr);
        } catch (ParseException ex) {
            throw ex;
        }
        return date == null ? null : new Timestamp(date.getTime());
    }
}

Related

  1. sqlTimestampToDate(Timestamp t)
  2. StrToDateTimeFormat(String timestampStr,String pattern)
  3. strToTimestamp(String date)
  4. strToTimestamp(String dateStr)
  5. strToTimestamp(String i_Today, String i_Hour, String i_Minute)
  6. timestamp()
  7. timestamp(int year, int month, int day, int hour, int minute, int second, int nanosecond)
  8. timestamp(Long param)
  9. timestampInMs()