Android Date Get getDate(int year, int month, int date, int hourOfDay, int minute, int second)

Here you can find the source of getDate(int year, int month, int date, int hourOfDay, int minute, int second)

Description

get Date

Declaration

public static Date getDate(int year, int month, int date,
            int hourOfDay, int minute, int second) 

Method Source Code

//package com.java2s;

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  a v  a2s  . c  o m*/

    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. getDate(String sDate, String dateFormat)
  2. getDateFromString(String dateStr, String pattern)
  3. getDateObj()
  4. getDateObj(String argsDate, String split)
  5. getDateObj(int year, int month, int day)