Here you can find the source of formatDateToTimestamp(String string)
Parameter | Description |
---|---|
string | a parameter |
public static Timestamp formatDateToTimestamp(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 { /**//from ww w.j ava2s . com * yyyy-MM-dd Comment for <code>onlyDateFmt</code> */ public static final SimpleDateFormat onlyDateFmt = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA); /** * yyyy-MM-dd * * @param string * @return */ public static Timestamp formatDateToTimestamp(String string) { Timestamp result = null; try { Date date = onlyDateFmt.parse(string); result = new Timestamp(date.getTime()); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } return result; } }