Android Date String to Date Convert convertStringToDate(String dateString, String currentFormat)

Here you can find the source of convertStringToDate(String dateString, String currentFormat)

Description

used to convert the specified date string to Date instance

Parameter

Parameter Description
dateString date string
currentFormat format string specifying the current format of date

Return

returns Date instance in "day MMM dd HH:MM:SS Timzone yyyy" format

Declaration

public static Date convertStringToDate(String dateString,
        String currentFormat) throws ParseException 

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 {
    /**/*from w  ww .  j a  v a 2 s .  c  om*/
     * used to convert the specified date string to Date instance
     * 
     * @param dateString date string
     * @param currentFormat format string specifying the current format of date
     * @return returns Date instance in "day MMM dd HH:MM:SS Timzone yyyy"
     *         format
     */
    public static Date convertStringToDate(String dateString,
            String currentFormat) throws ParseException {
        SimpleDateFormat dateFormat = new SimpleDateFormat(currentFormat,
                Locale.getDefault());
        return dateFormat.parse(dateString);
    }
}

Related

  1. parseDate(String date, SimpleDateFormat format)
  2. parseDate(String dateString)
  3. parseDateTime(String date)
  4. parseTaskWarrior(String date)
  5. getDate(String sDate, String dateFormat)
  6. dateToString(Date date, String format)
  7. parseStringToDate(String dateString, String sourceDateFormat, Locale locale)
  8. parse2Date(SimpleDateFormat s, Object d)
  9. stringToDate(String src, String format)