Android Date String Parse convertStringToDate(String date, String time)

Here you can find the source of convertStringToDate(String date, String time)

Description

convert String To Date

Declaration

public static Date convertStringToDate(String date, String time) 

Method Source Code

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

import java.util.Date;
import android.util.Log;

public class Main {
    private static String TAG = "DateTimeHelper";
    private static String invalidDateFormat = "Invalid date format";

    public static Date convertStringToDate(String date, String time) {
        SimpleDateFormat formatter = new SimpleDateFormat(
                "dd-MM-yyyy hh:mm a");
        String dateString = date + " " + time;
        Date newDate = null;//from   w w  w .ja  va2  s  . com

        try {
            newDate = (Date) formatter.parse(dateString);
        } catch (java.text.ParseException e) {
            Log.w(TAG, invalidDateFormat);
        }

        return newDate;
    }
}

Related

  1. tokenizeDate(String date)
  2. String2Date(String dateStr)
  3. changeDateWithSplit(String argDate, String split)
  4. isValidDate(String sDate)
  5. getDateTimeFromString(String dateTimeString, String format)
  6. GetDate(String time)
  7. dateTimeToDateObj(String date, String time)
  8. fromSlDateTime(final String dateString, final String timeString)
  9. convertTimeStumpToDate(String time)