Here you can find the source of stringToTimeStamp(String dateTimeString, String dateTimeFormat, TimeZone tz, Locale locale)
public static Timestamp stringToTimeStamp(String dateTimeString, String dateTimeFormat, TimeZone tz, Locale locale) throws ParseException
//package com.java2s; //License from project: Apache License import java.sql.Timestamp; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; import java.util.TimeZone; public class Main { /**// w ww .j a v a 2s.c om * Localized String to Timestamp conversion. To be used in tandem with * timeStampToString(). */ public static Timestamp stringToTimeStamp(String dateTimeString, TimeZone tz, Locale locale) throws ParseException { return stringToTimeStamp(dateTimeString, null, tz, locale); } /** * Localized String to Timestamp conversion. To be used in tandem with * timeStampToString(). */ public static Timestamp stringToTimeStamp(String dateTimeString, String dateTimeFormat, TimeZone tz, Locale locale) throws ParseException { DateFormat dateFormat = toDateTimeFormat(dateTimeFormat, tz, locale); Date parsedDate = dateFormat.parse(dateTimeString); return new Timestamp(parsedDate.getTime()); } /** * Returns an initialized DateFormat object. * * @param dateTimeFormat * optional format string * @param tz * @param locale * can be null if dateTimeFormat is not null * @return DateFormat object */ public static DateFormat toDateTimeFormat(String dateTimeFormat, TimeZone tz, Locale locale) { DateFormat df = null; if (dateTimeFormat == null) { df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM, locale); } else { df = new SimpleDateFormat(dateTimeFormat); } df.setTimeZone(tz); return df; } }