Android GMT Date Get getGMTDateFromString(String dateStr)

Here you can find the source of getGMTDateFromString(String dateStr)

Description

get GMT Date From String

License

Open Source License

Declaration

public static Date getGMTDateFromString(String dateStr)
        throws ParseException 

Method Source Code

//package com.java2s;
/**//  w  w  w. j  a  v  a 2s . c o m
 * 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;

public class Main {

    public static Date getGMTDateFromString(String dateStr)
            throws ParseException {

        return getDateFromString("E, dd MMM yyyy HH:mm:ss 'GMT'", dateStr);
    }

    public static Date getDateFromString(String dateString)
            throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat(
                "yyyy-MM-dd'T'hh:mm:ss.S'Z'");
        return sdf.parse(dateString);
    }

    public static Date getDateFromString(String format, String dateString)
            throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        return sdf.parse(dateString);
    }
}

Related

  1. getGMTDate()
  2. getGMTDate(Date date)
  3. getMillisGMT()
  4. millisToGMT(long millis)