Android Date String to Date Convert getDate(String sDate, String dateFormat)

Here you can find the source of getDate(String sDate, String dateFormat)

Description

get Date

License

Apache License

Declaration

public static Date getDate(String sDate, String dateFormat) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class Main {
    public static Date getDate(String sDate, String dateFormat) {
        SimpleDateFormat fmt = new SimpleDateFormat(dateFormat);
        ParsePosition pos = new ParsePosition(0);

        return fmt.parse(sDate, pos);
    }//from  w w  w .j  ava  2s .c om

    public static Date getDate(int year, int month, int date,
            int hourOfDay, int minute, int second) {
        Calendar cal = new GregorianCalendar();
        cal.set(year, month, date, hourOfDay, minute, second);
        return cal.getTime();
    }
}

Related

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