Uses {@link SimpleDateFormat} to translate the supplied {@link
Long} or {@link Date} argument into a formatted date string using
the locale appropriate to the current request.
542988
public String date (String format, Object arg)
    {
        Date when = massageDate(arg);
        if (when == null) {
            return format;
        }
        SimpleDateFormat fmt = new SimpleDateFormat(format, getLocale());
        return fmt.format(when);
    }
840163
public static String formatDate(String format, Locale loc) {
		return formatDate(timestamp(), format, loc);
	}
950408
public static String formatDate(final Date value, final String pattern)
    {
        return new SimpleDateFormat(pattern, currentLocale()).format(value);
    }
137251
private static String convertDateElementToString(Date currentDate, SimpleDateFormat dateFormat) {
        return currentDate.getTime() != 0 ? dateFormat.format(currentDate.getTime()) : "";
    }
408249
private static Date extractDate(String text, Locale locale) {
		DateFormat fmt;
		for (int style = 0; style <= 3; ++style) {
			// Date and time parsing
			for (int style2 = 0; style2 <= 3; ++style2) {
				fmt = DateFormat.getDateTimeInstance(style, style2, locale);
				try {
					return fmt.parse(text);
				} catch (ParseException exception) {
					//
				}
			}
			// Date only parsing
			fmt = DateFormat.getDateInstance(style, locale);
			try {
				return fmt.parse(text);
			} catch (ParseException exception) {
				//
			}
			// Time only parsing
			fmt = DateFormat.getTimeInstance(style, locale);
			try {
				return fmt.parse(text);
			} catch (ParseException exception) {
				//
			}
		}
		return null;
	}
570099
public String convertDateToString(final Date date) {
        if (date == null) {
            return null;
        }
        return dateFormat.get().format(date);
    }
854630
public static String getDateFormat(final Date date, final String pattern) {

    SimpleDateFormat simpleDateFormat = buildDateFormat(pattern);
    return simpleDateFormat.format(date);
  }
648913
@Benchmark
	@BenchmarkMode(Mode.Throughput)
	public String formatDate() {
		synchronized (SIMPLE_DATE_FORMAT) {
			return SIMPLE_DATE_FORMAT.format(DATE);
		}
	}
958205
private static String formatDate(Date date) {

        String dateStr = dateFormat.format(date);
        // insert colon into timezone
        return dateStr.substring(0, 22) + ":" + dateStr.substring(22);
    }
240163
public static String getFormattedDate(final Long lastQueryDate, final String datePattern) {
        return formatDate(lastQueryDate, null, datePattern);
    }
695344
function formatDate(date, format)
  {
    let parsedDate = new Date(date)
    if (!isDate(parsedDate))
      throw new TypeError("A date or timestamp must be provided to {{formatDate}}")

    if (isString(format) && format in formats.date)
      format = formats.date[format]

    return getCachedDateTimeFormat(locale, format).format(parsedDate)
  }
980632
public SimpleDateFormat build() {
        
        final SimpleDateFormat formatter;
        if(locale == null) {
            formatter = new SimpleDateFormat(pattern);
        } else {
            formatter = new SimpleDateFormat(pattern, locale);
        }
        
        if(timeZone != null) {
            formatter.setTimeZone(timeZone);
        }
        formatter.setLenient(lenient);
        
        return formatter;
        
    }
223143
static public String getDateAsString(
      Date date, SnowflakeDateTimeFormat dateFormatter)
  {
    return dateFormatter.format(date, timeZoneUTC);
  }
411855
public static String convert(String date, String format, String newFormat) {
        return getFormatDate(newFormat, parse(date, format));
    }
889734
@Nonnull
    @SuppressFBWarnings("RV_RETURN_VALUE_IGNORED_BAD_PRACTICE")
    public String format(@Nonnull Date date) {
        SimpleDateFormat dateFormat = dateFormats.poll();
        if (dateFormat == null) {
            dateFormat = new SimpleDateFormat(pattern, locale);
            dateFormat.setTimeZone(timeZone);
        }
        try {
            return dateFormat.format(date);
        } finally {
            dateFormats.offer(dateFormat);
        }
    }
625368
public static final String formatTime(long timestamp) {
        DateFormat sdf = dateformats.get();
        if (sdf == null) {
            sdf = getDateFormat();
            dateformats.set(sdf);
        }
        return sdf.format(timestamp);
    }
943509
public static Date stringToDate(String dateText, String format,
                                    boolean lenient) {

        if (dateText == null) {

            return null;
        }

        DateFormat df = null;

        try {

            if (format == null) {
                df = new SimpleDateFormat();
            } else {
                df = new SimpleDateFormat(format);
            }

            // setLenient avoids allowing dates like 9/32/2001
            // which would otherwise parse to 10/2/2001
            df.setLenient(false);

            return df.parse(dateText);
        } catch (ParseException e) {

            return null;
        }
    }