Here you can find the source of parseDate(String text)
public static Date parseDate(String text)
//package com.java2s; //License from project: Apache License import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { private static final Pattern TZ_REGEX = Pattern.compile("([+-][0-9][0-9]):?([0-9][0-9])$"); public static Date parseDate(String text) { if (text == null) return null; Matcher matcher = TZ_REGEX.matcher(text); TimeZone timeZone = null; if (matcher.find()) { String tzCode = "GMT" + matcher.group(1) + matcher.group(2); // eg "GMT+0100" timeZone = TimeZone.getTimeZone(tzCode); }/*w w w. j a v a 2s . c o m*/ DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); if (timeZone != null) { formatter.setTimeZone(timeZone); } try { Date result = formatter.parse(text); return result; } catch (ParseException e) { return null; } } }