Android Date String to Date Convert str2Date(String str)

Here you can find the source of str2Date(String str)

Description

str Date

Declaration

public static String str2Date(String str) 

Method Source Code

//package com.java2s;
import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Date;

import java.util.Locale;

public class Main {
    public static String str2Date(String str) {
        SimpleDateFormat sdf = new SimpleDateFormat(
                "EEE MMM dd HH:mm:ss zzz yyyy", Locale.US);
        Date date = null;/*  w w  w .  j a va 2  s .  com*/
        try {
            date = (Date) sdf.parse(str);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        String formatStr = new SimpleDateFormat("yy-MM-dd").format(date);
        return formatStr;
    }
}

Related

  1. string2Date(String s, String s1)
  2. stringToDate(SimpleDateFormat dateFormat, String dateToConvert, boolean catchError)
  3. stringToDate(String paramString1, String paramString2, boolean paramBoolean)
  4. toDate(String s)
  5. toDateFromString(String dateString)
  6. global2Date(String str)