Here you can find the source of convertStringToTime(String date, String pattern)
public static Date convertStringToTime(String date, String pattern) throws ParseException
//package com.java2s; /*/*from w w w . j a v a2 s. com*/ * Copyright (C) 2010 Viettel Telecom. All rights reserved. * VIETTEL PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class Main { public static Date convertStringToTime(String date, String pattern) throws ParseException { if (date == null || "".equals(date.trim())) { return null; } SimpleDateFormat dateFormat = new SimpleDateFormat(pattern, Locale.ENGLISH); return dateFormat.parse(date); } }