Here you can find the source of parseDateTimeToTimestamp(String string)
Parameter | Description |
---|---|
string | a parameter |
public static Timestamp parseDateTimeToTimestamp(String string)
//package com.java2s; //License from project: Apache License import java.sql.Timestamp; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class Main { /**/* w w w . j a va 2 s .c o m*/ * yyyy-MM-dd HH:mm:ss Comment for <code>allDateFmt</code> */ public static final SimpleDateFormat allDateFmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA); /** * yyyy-MM-dd HH:mm:ss * * @param string * @return */ public static Timestamp parseDateTimeToTimestamp(String string) { Timestamp result = null; try { Date date = allDateFmt.parse(string); result = new Timestamp(date.getTime()); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } return result; } }