Android Date Get getDateFromString(String dateString)

Here you can find the source of getDateFromString(String dateString)

Description

get Date From String

Declaration

@SuppressLint("SimpleDateFormat")
    public static Date getDateFromString(String dateString) 

Method Source Code

//package com.java2s;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import android.annotation.SuppressLint;
import android.text.TextUtils;

public class Main {
    private static final String DATE_FORMAT = "EEE, d MMM yyyy HH:mm:ss Z";

    @SuppressLint("SimpleDateFormat")
    public static Date getDateFromString(String dateString) {
        if (!TextUtils.isEmpty(dateString)) {
            SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
            try {
                return sdf.parse(dateString);
            } catch (ParseException e) {
                e.printStackTrace();/*from   w w w  . ja va 2  s.  com*/
            }
        }
        return null;
    }
}

Related

  1. getDateObj()
  2. getDate(int year, int month, int date, int hourOfDay, int minute, int second)
  3. getCurrentDateYearMonthDateHourMinuteSecond()
  4. createDate(final int month, final int day, final int year)
  5. getDate(int year, int month)
  6. getCurrentlyDate()
  7. getDate(int day, int month, int year)