Java tutorial
//package com.java2s; /** * Copyright (c) 2012 The Wiseserc. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ 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 getGMTDateFromString(String dateStr) throws ParseException { return getDateFromString("EEE, dd MMM yyyy HH:mm:ss 'GMT'", dateStr); } public static Date getDateFromString(String dateString) throws ParseException { return getDateFromString("yyyy-MM-dd'T'hh:mm:ss.S'Z'", dateString); } public static Date getDateFromString(String format, String dateString) throws ParseException { Locale locale = Locale.ENGLISH; SimpleDateFormat sdf = new SimpleDateFormat(format, locale); sdf.setTimeZone(TimeZone.getTimeZone("GMT")); return sdf.parse(dateString); } }