Java Timestamp Parse parseTimestamp(String dateStr, String format)

Here you can find the source of parseTimestamp(String dateStr, String format)

Description

parse Timestamp

License

Apache License

Declaration

public static java.sql.Timestamp parseTimestamp(String dateStr, String format) 

Method Source Code

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

import java.util.*;
import java.text.*;

public class Main {

    public static java.sql.Timestamp parseTimestamp(String dateStr, String format) {
        java.util.Date date = parseDate(dateStr, format);
        if (date != null) {
            long t = date.getTime();
            return new java.sql.Timestamp(t);
        } else/*from   w ww  . j  a  v a2 s.co m*/
            return null;
    }

    public static Date parseDate(java.sql.Date date) {
        return date;
    }

    public static java.util.Date parseDate(String dateStr, String formatStr) {
        SimpleDateFormat format = new SimpleDateFormat(formatStr);
        try {
            return format.parse(dateStr);
        } catch (ParseException e) {
            e.printStackTrace();
            return null;
        }
    }
}

Related

  1. parseTimeStamp(final String... key)
  2. parseTimestamp(Long time, String pattern)
  3. parseTimestamp(Object o)
  4. parseTimestamp(String d)
  5. parseTimestamp(String date)
  6. parseTimestamp(String dateString)
  7. parseTimestamp(String pattern, String dateTime)
  8. parseTimestamp(String s)
  9. parseTimestamp(String s)