Android Date String to Date Convert global2Date(String str)

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

Description

global Date

Declaration

public static String global2Date(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 global2Date(String str) {

        SimpleDateFormat sdf = new SimpleDateFormat(
                "EEE MMM dd HH:mm:ss zzz yyyy", Locale.US);
        Date date = null;//from w w w . j  a v a  2  s .c  o  m
        try {
            date = (Date) sdf.parse(str);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        String formatStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
                .format(date);
        System.out.println(formatStr);
        return formatStr;
    }
}

Related

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