Java SQL Time Create getTime(String time)

Here you can find the source of getTime(String time)

Description

get Time

License

Open Source License

Declaration

public static Timestamp getTime(String time) 

Method Source Code

//package com.java2s;
/*/* w  w  w.j a  v a 2 s  .c o m*/
* This file is part of BillMining.
* 
* BillMining is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3
* as published by the Free Software Foundation.
*
* BillMining is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.  <http://www.gnu.org/licenses/>
*
* Author(s):
*
* ? 2015 Kasra Madadipouya <kasra@madadipouya.com>
*/

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

public class Main {
    public static Timestamp getTime(String time) {
        Timestamp timestamp = null;
        try {
            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS");
            java.util.Date parsedDate = dateFormat.parse(time);
            timestamp = new java.sql.Timestamp(parsedDate.getTime());
        } catch (Exception e) {//this generic but you can control another types of exception
            e.printStackTrace();
        }
        return timestamp;
    }
}

Related

  1. getTime(Map map, String attr)
  2. getTime(Object value)
  3. getTime(Object value, int columnType)
  4. getTime(ResultSet resultSet, String columnName)
  5. getTime(ResultSet rs, String column)
  6. getTimeAndDateStamp(String line)
  7. getTimeBy(int hour)
  8. getTimeFormat()
  9. getTimeFromCalendar(final Calendar calendar)