Here you can find the source of convertStringDateToTimestamp(String sDate, String dateformat)
Parameter | Description |
---|---|
date | a parameter |
dateformat | a parameter |
public static Timestamp convertStringDateToTimestamp(String sDate, String dateformat)
//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 { /****//www. j a v a2s .c o m * * @param date * @param dateformat * @return Timestamp */ public static Timestamp convertStringDateToTimestamp(String sDate, String dateformat) { SimpleDateFormat dateFormat; Date date; Timestamp timestamp = null; try { dateFormat = new SimpleDateFormat(dateformat); date = dateFormat.parse(sDate); timestamp = new Timestamp(date.getTime()); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } return timestamp; } }