Java Utililty Methods Date Create

List of utility methods to do Date Create

Description

The list of methods to do Date Create are organized into topic(s).

Method

Datedate(int year, int month, int day, int hour, int minute, int second)
date
Calendar calendar = Calendar.getInstance();
calendar.set(year, month, day, hour, minute, second);
calendar.set(Calendar.MILLISECOND, 0);
return calendar.getTime();
Date[]longArrayTODateArray(long[] dates_s, SimpleDateFormat dateformat)
long Array TO Date Array
if (dates_s == null) {
    return null;
Date[] dates = new Date[dates_s.length];
for (int i = 0; i < dates_s.length; i++) {
        dates[i] = new Date(dates_s[i]);
return dates;
StringlongToDate(long time)
Parsing long value to the Date format
Date date = new Date(time);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
return format.format(date);
DateobjectToDate(Object Obj)
object To Date
SimpleDateFormat formatoDelTexto = new SimpleDateFormat("yyyy-MM-dd");
Date aux = null;
try {
    aux = formatoDelTexto.parse(objectToString(Obj));
} catch (Exception ex) {
return aux;
StringtimeToDate()
time To Date
Calendar cal = Calendar.getInstance();
SimpleDateFormat dateParser = new SimpleDateFormat("MMM d HH:mm:ss", Locale.getDefault());
return dateParser.format(cal.getTime());
StringtoDate()
to Date
Date date = new Date();
return daysParse.format(date);
StringtoDate()
to Date
return toDate(new Date());
StringtoDate(Calendar date)
to Date
String dateFormatted = "";
if (date != null) {
    dateFormatted = sdfDate.format(date.getTime());
return dateFormatted;
StringtoDate(Date d)
to Date
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd/MM/yyyy");
StringBuilder fieldDate = new StringBuilder(simpleDateFormat.format(d));
return fieldDate.toString();
DatetoDate(final Calendar calendar)
To date.
Date date = new Date();
date = calendar.getTime();
return date;