Here you can find the source of getTimestampFromString(String dateString, String dateFormat)
Parameter | Description |
---|---|
dateString | a parameter |
dateFormat | a parameter |
Parameter | Description |
---|---|
ParseException | an exception |
public static Timestamp getTimestampFromString(String dateString, String dateFormat) throws ParseException
//package com.java2s; //License from project: LGPL import java.sql.Timestamp; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { /**/* ww w . j av a 2s . co m*/ * Trasform a date string into a timestamp * @param dateString * @param dateFormat * @return * @throws ParseException */ public static Timestamp getTimestampFromString(String dateString, String dateFormat) throws ParseException { SimpleDateFormat format = new SimpleDateFormat(dateFormat); Date parsedDate = format.parse(dateString); Timestamp ts = new Timestamp(parsedDate.getTime()); return ts; } }