Here you can find the source of parseTime(String text)
public static Date parseTime(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 parseTime(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); }//from ww w . j a v a2 s . c om DateFormat formatter = new SimpleDateFormat("HH:mm:ss"); if (timeZone != null) { formatter.setTimeZone(timeZone); } try { Date result = formatter.parse(text); return result; } catch (ParseException e) { return null; } } }