Converts the specified <code>date</code> with the specified {@code format} to a new instance of Time.
<code>null</code> is returned if the specified <code>date</code> is null or empty.

@param date
@param format
@param timeZone
@return
9213
public static Time parseTime(final String date, final String format, final TimeZone timeZone) {
        if (N.isNullOrEmpty(date) || (date.length() == 4 && "null".equalsIgnoreCase(date))) {
            return null;
        }

        return createTime(parse(date, format, timeZone));
    }
83708
public static Date fromJavaUtilDate(java.util.Date date) {
    Calendar cal = Calendar.getInstance();
    cal.setTime(date);
    cal.set(Calendar.HOUR_OF_DAY, 0);
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.MILLISECOND, 0);
    // Calender.MONTH starts from 0 while G C date starts from 1
    return new Date(
        cal.get(Calendar.YEAR), cal.get(Calendar.MONTH) + 1, cal.get(Calendar.DAY_OF_MONTH));
  }
1274678
private static String formatDate(Date date) {
        SimpleDateFormat formatter = new SimpleDateFormat(
                "yyyy-MM-dd'T'HH:mm:ss'Z'");
        formatter.setTimeZone(TimeZone.getTimeZone("GMT"));
        return formatter.format(date);
    }
663343
public static Calendar parseCalendar(final String calendar, final String format, final TimeZone timeZone) {
        if (N.isNullOrEmpty(calendar) || (calendar.length() == 4 && "null".equalsIgnoreCase(calendar))) {
            return null;
        }

        return createCalendar(parse(calendar, format, timeZone));
    }
89357
@Transformer(requireTemplate = true)
    public static String format(Date date) {
        return format(date, null, null, null);
    }
832242
public static function createFromFormat($format, $date, $tz = null) {
        
        if ($tz !== null) {
            $tz = static::safeCreateDateTimeZone($tz);
        }
        
        $instance = new static($tz);
        
        $instance->parseFormat($format, $date);
        
        return $instance;
    }
1329322
public static String format( DateTimeFormat format, Date date ) {
        return format( format, UTC_TIMEZONE, date );
    }
186578
public static String format(final Date date, final String pattern) {
        return format(date, pattern, null, null);
    }
928768
public static String format(Date date, DateFormat format) {
		if (null == format || null == date) {
			return null;
		}
		return format.format(date);
	}
1086368
public static DateTime toDateTime(String input, String format, String timezone) {
    String tz = StringUtils.defaultString(timezone, ConfigurationKeys.DEFAULT_SOURCE_TIMEZONE);
    DateTimeZone dateTimeZone = getTimeZone(tz);
    DateTimeFormatter inputDtFormat = DateTimeFormat.forPattern(format).withZone(dateTimeZone);
    DateTime outputDateTime = inputDtFormat.parseDateTime(input).withZone(dateTimeZone);
    return outputDateTime;
  }
776326
private DateTime zonedDateTimeToJodaTime(final ChronoZonedDateTime<?> date) {
        return date == null ? null : new DateTime(date.toInstant().toEpochMilli(), DateTimeZone.UTC);
    }
1313596
public static String format(Locale locale, TimeZone timeZone, String pattern, Date date) {
	synchronized (data) {
	    String key = locale.toString() + '-' + timeZone.getID() + '-' + pattern;
	    Object obj = data.get(key);
	    if (obj != null) {
		return ((SimpleDateFormat) obj).format(date);
	    }
	    SimpleDateFormat sdf = new SimpleDateFormat(pattern, locale);
	    sdf.setTimeZone(timeZone);
	    data.put(key, sdf);
	    return sdf.format(date);
	}
    }
194928
public static function FromFormat( string $format, $time, \DateTimeZone $timezone = null ) : DateTime
   {
      if ( $timezone !== null )
      {
         $dt = parent::createFromFormat( $format, $time, $timezone );
      }
      else
      {
         $dt = parent::createFromFormat( $format, $time );
      }

      if ( $dt instanceof \DateTime )
      {
         return static::FromDateTime( $dt );
      }

      throw new ArgumentError(
         'format',
         $format,
         'Date',
         \join( \PHP_EOL, parent::getLastErrors() )
      );

   }
1225262
static public long getDateTime(String s, String format, TimeZone tz)
    {
        long ret = 0L;
        SimpleDateFormat df = null;

        try
        {
            if(s != null && s.length() > 0)
            {
                df = formatPool.getFormat(format);
                df.setTimeZone(tz);
                Date dt = df.parse(s);
                ret = dt.getTime();
            }
        }
        catch(Exception e)
        {
        }

        if(df != null)
            formatPool.release(df);

        return ret;
    }
486059
public static String format( DateTimeFormat format, TimeZone timeZone, Date date ) {
        return format.format( date, timeZone );
    }
222704
public static ICalDate convert(DateValue date, TimeZone timezone) {
		Calendar c = Calendar.getInstance(timezone);
		c.clear();
		c.set(Calendar.YEAR, date.year());
		c.set(Calendar.MONTH, date.month() - 1);
		c.set(Calendar.DATE, date.day());

		boolean hasTime = (date instanceof DateTimeValue);
		if (hasTime) {
			DateTimeValue dateTime = (DateTimeValue) date;
			c.set(Calendar.HOUR_OF_DAY, dateTime.hour());
			c.set(Calendar.MINUTE, dateTime.minute());
			c.set(Calendar.SECOND, dateTime.second());
		}

		return new ICalDate(c.getTime(), hasTime);
	}
559960
public static Date parseDate(String date) {
        if (date == null) {
            return null;
        }
        try {
            return org.apache.commons.lang.time.DateUtils.parseDate(date, new String[] {DSP_DEFAULT_TIME_FORMAT});
        } catch (ParseException e) {
            return null;
        }
    }