Java Parse Date Pattern YYYY parse(String source)

Here you can find the source of parse(String source)

Description

parse

License

Open Source License

Parameter

Parameter Description
source a parameter

Return

Date

Declaration

public static Date parse(String source) 

Method Source Code

//package com.java2s;
/*//ww w  .  j a  v a  2 s .  c  om
 * $RCSfile: GMTUtil.java,v $$
 * $Revision: 1.1  $
 * $Date: 2007-5-29  $
 *
 * Copyright (C) 2008 Skin, Inc. All rights reserved.
 *
 * This software is the proprietary information of Skin, Inc.
 * Use is subject to license terms.
 */

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;

public class Main {
    private static String DATE_FORMAT_GMT = "EEE, dd MMM yyyy HH:mm:ss z";
    private static Locale local = Locale.ENGLISH;
    private static TimeZone timeZone = TimeZone.getTimeZone("GMT");

    /**
     * @param source
     * @return Date
     */
    public static Date parse(String source) {
        Date date = null;

        try {
            DateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT_GMT,
                    local);
            dateFormat.setTimeZone(timeZone);

            date = dateFormat.parse(source);
        } catch (Exception e) {
            e.printStackTrace();
        }

        return date;
    }
}

Related

  1. parse(String s)
  2. parse(String s)
  3. parse(String s)
  4. parse(String s)
  5. parse(String s, String formatPattern)
  6. parse(String source)
  7. parse(String source)
  8. parse(String source, Date defaultValue)
  9. parse(String str)