Java Timestamp Field getstrTimestamp(String datetime)

Here you can find the source of getstrTimestamp(String datetime)

Description

getstr Timestamp

License

Apache License

Declaration

public static Timestamp getstrTimestamp(String datetime) 

Method Source Code


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

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

import java.text.SimpleDateFormat;

public class Main {

    public static Timestamp getstrTimestamp(String datetime) {
        java.util.Date bb = new java.util.Date(datetime);
        if (bb != null) {
            return new Timestamp(bb.getTime());
        } else {// w  w  w  . j a v a  2s .  c  o  m
            return null;
        }
    }

    public static Timestamp getstrTimestamp(String datetime, String datepattern) {
        java.util.Date bb = null;

        try {
            DateFormat parser = new SimpleDateFormat(datepattern);
            bb = parser.parse(datetime);
            return new Timestamp(bb.getTime());
        } catch (ParseException ex) {
        }
        return null;
    }
}

Related

  1. getSQLTimeStampForDate(Date date)
  2. getSqlTimestampFromMicrosSinceEpoch( long timestamp)
  3. getSqlTimestampFromShortDate(String date)
  4. getStamp(Timestamp timestamp)
  5. getStringToTimestamp(String str)
  6. getSysDateTimestamp()
  7. getSystemTimestamp()
  8. getSystemTimestamp()
  9. getWeekEnd(Timestamp stamp, TimeZone timeZone, Locale locale)