Here you can find the source of getUTCDateFromString(String date)
public static Date getUTCDateFromString(String date) throws ParseException, Exception
//package com.java2s; //License from project: Open Source License 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 { public static Date getUTCDateFromString(String date) throws ParseException, Exception { DateFormat df = new SimpleDateFormat("yyyyMMddHHmmss", Locale.ENGLISH); Date result = df.parse(date); return getUTCDate(result.getTime()); }/*w w w.j av a 2 s .co m*/ public static Date getUTCDate(Long milliseconds) { //Date converted to UTC if (milliseconds == null) return null; TimeZone currentTimezone = TimeZone.getDefault(); Date currentDateUTC = new Date(milliseconds - currentTimezone.getRawOffset()); return currentDateUTC; } }