Java Utililty Methods Calendar to Date

List of utility methods to do Calendar to Date

Description

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

Method

DatecalendarToDate(Calendar c)
Returns a java Calendar as a Date.
if (c == null) {
    return null;
return new Date(c.getTimeInMillis());
DatecalendarToDate(Calendar cal)
calendar To Date
return cal.getTime();
intcalendarToDateId(Calendar cal)
Convert a calendar to a date id
return cal.get(Calendar.YEAR) * 10000 + (cal.get(Calendar.MONTH) + 1) * 100
        + cal.get(Calendar.DAY_OF_MONTH);
java.util.DategetDate(Calendar cal)
Returns the current time from a calendar object
java.util.Date convertedDate = null;
try {
    SimpleDateFormat formatter = (SimpleDateFormat) SimpleDateFormat.getDateInstance(DateFormat.SHORT);
    formatter.applyPattern("M/d/yyyy");
    String tmpDate = (cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.DAY_OF_MONTH) + "/"
            + cal.get(Calendar.YEAR);
    convertedDate = formatter.parse(tmpDate);
} catch (Exception e) {
...
DatetoDate(Calendar cal)
to Date
if (cal != null) {
    return cal.getTime();
return null;
DatetoDate(Calendar calendar)
Converts a java.util.Calendar to a java.util.Date.
return calendar.getTime();
DatetoDate(Calendar calender)
to Date
return calender.getTime();
DatetoDate(Calendar input)
Converts the given Calendar object to a Date object.
if (input == null)
    return null;
return input.getTime();
DatetoDate(final Calendar calendar)
Converts a Calendar-object to a Date.
final Date date = calendar.getTime();
return date;