Here you can find the source of to_timestamp(String date)
public static Timestamp to_timestamp(String date)
//package com.java2s; //License from project: Open Source License import java.sql.Timestamp; import java.util.Calendar; import java.util.Date; import java.util.StringTokenizer; public class Main { public static Timestamp to_timestamp(String date) { return new Timestamp(to_date(date).getTime()); }/*from www . j av a 2 s. co m*/ public static Date to_date(String date) { Calendar cd = Calendar.getInstance(); StringTokenizer token = new StringTokenizer(date, "-/ :"); if (token.hasMoreTokens()) { cd.set(Calendar.YEAR, Integer.parseInt(token.nextToken())); } else { cd.set(Calendar.YEAR, 1970); } if (token.hasMoreTokens()) { cd.set(Calendar.MONTH, Integer.parseInt(token.nextToken()) - 1); } else { cd.set(Calendar.MONTH, 0); } if (token.hasMoreTokens()) { cd.set(Calendar.DAY_OF_MONTH, Integer.parseInt(token.nextToken())); } else { cd.set(Calendar.DAY_OF_MONTH, 1); } if (token.hasMoreTokens()) { cd.set(Calendar.HOUR_OF_DAY, Integer.parseInt(token.nextToken())); } else { cd.set(Calendar.HOUR_OF_DAY, 0); } if (token.hasMoreTokens()) { cd.set(Calendar.MINUTE, Integer.parseInt(token.nextToken())); } else { cd.set(Calendar.MINUTE, 0); } if (token.hasMoreTokens()) { cd.set(Calendar.SECOND, Integer.parseInt(token.nextToken())); } else { cd.set(Calendar.SECOND, 0); } if (token.hasMoreTokens()) { cd.set(Calendar.MILLISECOND, Integer.parseInt(token.nextToken())); } else { cd.set(Calendar.MILLISECOND, 0); } return cd.getTime(); } }