Java Calendar Time getCurrentTimeIfCalendareIsNull(Calendar testDate)

Here you can find the source of getCurrentTimeIfCalendareIsNull(Calendar testDate)

Description

Returns the testDate if it has a value otherwise returns the current time.

License

Open Source License

Parameter

Parameter Description
testDate The date being testsed.

Return

the testDate if it has a value otherwise returns the current time.

Declaration

public static Date getCurrentTimeIfCalendareIsNull(Calendar testDate) 

Method Source Code

//package com.java2s;

import java.util.Calendar;
import java.util.Date;

public class Main {
    /**//  ww w .j a v  a  2  s .  c  om
     * Returns the testDate if it has a value otherwise returns the current time.
     * @param testDate The date being testsed.
     * @return the testDate if it has a value otherwise returns the current time.
     */
    public static Date getCurrentTimeIfCalendareIsNull(Calendar testDate) {
        if (testDate == null) {
            return Calendar.getInstance().getTime();
        } else {
            return testDate.getTime();
        }
    }
}

Related

  1. equalizeTime(final Calendar toEqualize, final Calendar source)
  2. equalsIgnoreTimeZone(final Calendar c1, final Calendar c2)
  3. getCalendarWithoutTimeZone(Date date)
  4. getClientCurrentDate(final Calendar calendar, final TimeZone timeZone)
  5. getCurrentTimeDecimal(Calendar cal)
  6. getCurrentTimeLongType(Calendar cal)
  7. getCurrentTimeZoneCalendar(String timeZone)
  8. getDateTimeByDate(Date date, int calendarType, int qty)
  9. getFullTimeToString(Calendar argCal)