Android Date String Parse convertStringToDate(String strDate, String pattern)

Here you can find the source of convertStringToDate(String strDate, String pattern)

Description

convert String To Date

Declaration

public static Date convertStringToDate(String strDate, String pattern) 

Method Source Code

//package com.java2s;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

public class Main {
    public static Date convertStringToDate(String strDate, String pattern) {
        DateFormat df = new SimpleDateFormat(pattern, Locale.US);

        Date date = null;//  w w  w .  ja v  a  2 s  .c om
        strDate = strDate.replace("T", " ");
        try {
            date = df.parse(strDate);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return date;
    }
}

Related

  1. dateTimeToDateObj(String date, String time)
  2. fromSlDateTime(final String dateString, final String timeString)
  3. convertTimeStumpToDate(String time)
  4. convertimeStumpToDate2(String time)
  5. convertDateTimeStrFormat(String dateStr, String pattern, String newPattern)
  6. parse(String pattern, String date)
  7. parse3339(String time)
  8. parseDate(String date)
  9. parseDate(String date)