Accepts our ElasticSearch time formats without milliseconds.

@return A DateTimeFormatter suitable to parse an ES_DATE_FORMAT formatted string to a
DateTime Object even if it contains no milliseconds.
357250
public static DateTimeFormatter timeFormatterWithOptionalMilliseconds() {
        // This is the .SSS part
        DateTimeParser ms = new DateTimeFormatterBuilder()
                .appendLiteral(".")
                .appendFractionOfSecond(1, 3)
                .toParser();

        return new DateTimeFormatterBuilder()
                .append(DateTimeFormat.forPattern(ES_DATE_FORMAT_NO_MS).withZoneUTC())
                .appendOptional(ms)
                .toFormatter();
    }
265281
def format_date(cls, timestamp):
        
        if not timestamp:
            raise DateTimeFormatterException('timestamp must a valid string {}'.format(timestamp))

        return timestamp.strftime(cls.DATE_FORMAT)
926202
function getFormatter(oType) {
		var oFormatOptions;

		if (!oType.oFormat) {
			oFormatOptions = jQuery.extend({strictParsing : true}, oType.oFormatOptions);
			oFormatOptions.UTC = true;
			oType.oFormat = DateFormat.getTimeInstance(oFormatOptions);
		}
		return oType.oFormat;
	}
129247
public static DateTimeFormatter getDateTimeFormatter(String timeFormat) {
        return JMMap
                .getOrPutGetNew(dateTimeFormatterCache, timeFormat,
                        () -> DateTimeFormatter.ofPattern(timeFormat));
    }
1152407
public java.text.DateFormat getTimeFormat() {
        if(timeFormat == null)
            timeFormat = java.text.DateFormat.getTimeInstance(java.text.DateFormat.SHORT);
        return timeFormat;
    }
23215
private static ImmutableList<DateTimeFormatter> buildDefaultDateTimeFormatter() {

        return ImmutableList.<DateTimeFormatter>builder()
                    .add(DateTimeFormatter.ISO_LOCAL_DATE_TIME) // ISO with 'T'
                    .add(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss[[.SSSSSSSSS][.SSSSSSS][.SSSSSS][.SSS][.SS][.S][XXXXX][XXXX][x]")) // ISO without 'T'
//               new DateTimeFormatterBuilder().parseLenient().appendPattern("yyyy-MM-dd HH:mm:ss[XXXXX][XXXX][x]").appendFraction(ChronoField.MICRO_OF_SECOND, 0, 9, true)
                    .add(DateTimeFormatter.ISO_DATE) // ISO with or without time
                    .add(new DateTimeFormatterBuilder().parseCaseInsensitive().appendPattern("dd-MMM-yy[ HH:mm:ss]").toFormatter()) // another common case
                    .build();
    }
1140944
public static Format getFormatter(@Nonnull final Locale locale, @Nonnull final String format,
                                      @Nullable final Class<?>... type) {
        Format formatter = null;
        Pattern TEXT_FORMAT_STRING = Pattern.compile("^\\{([^}]+)}(.+)$");
        Matcher matcher = TEXT_FORMAT_STRING.matcher(format);
        if (matcher.matches()) {
            switch (matcher.group(1)) {
                case "Message":
                    formatter = new MessageFormat(matcher.group(2), locale);
                    break;
                case "Date":
                    formatter = new SimpleDateFormat(matcher.group(2), locale);
                    break;
                case "String":
                    formatter = new FormatterFormat(matcher.group(2), locale);
                    break;
                default:
                case "Log":
                    formatter = new LoggerFormat(matcher.group(2));
                    break;
            }
        } else {
            if (type != null && type.length == 1 && type[0] != null &&
                    (Calendar.class.isAssignableFrom(type[0]) || Date.class.isAssignableFrom(type[0]))) {
                formatter = new SimpleDateFormat(format, locale);
            } else {
                formatter = new LoggerFormat(format);
            }
        }
        return formatter;
    }
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);
        }
    }
1215930
static public String getSFTimeAsString(
      SFTime sft, int scale, SnowflakeDateTimeFormat timeFormatter)
  {
    return timeFormatter.format(sft, scale);
  }
1238450
public static Instant parse(String str, DateTimeFormatter formatter) {
        return formatter.parseDateTime(str).toInstant();
    }
148371
public static DateFormat getDateFormatter() {
        SoftReference<DateFormat> ref = dateFormatter.get();
        DateFormat formatter = ref != null ? ref.get() : null;
        if (formatter == null) {
            formatter = new SimpleDateFormat(DATE_FORMAT);
            formatter.setCalendar(new GregorianCalendar(new SimpleTimeZone(0, "GMT")));
            dateFormatter.set(new SoftReference<DateFormat>(formatter));
        }
        return formatter;
    }
625368
public static final String formatTime(long timestamp) {
        DateFormat sdf = dateformats.get();
        if (sdf == null) {
            sdf = getDateFormat();
            dateformats.set(sdf);
        }
        return sdf.format(timestamp);
    }
1024740
function (timeFormat) {
		var tf = timeFormat.replace(/'.*?'/g, '').toLowerCase(), // removes literals
			isIn = function (f, t) { // does the format contain the token?
					return f.indexOf(t) !== -1 ? true : false;
				};
		return {
				hour: isIn(tf, 'h'),
				minute: isIn(tf, 'm'),
				second: isIn(tf, 's'),
				millisec: isIn(tf, 'l'),
				microsec: isIn(tf, 'c'),
				timezone: isIn(tf, 'z'),
				ampm: isIn(tf, 't') && isIn(timeFormat, 'h'),
				iso8601: isIn(timeFormat, 'Z')
			};
	}
1322680
public String toTimeStr() {
		if (null != this.timeZone) {
			final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DatePattern.NORM_TIME_PATTERN);
			simpleDateFormat.setTimeZone(this.timeZone);
			return toString(simpleDateFormat);
		}
		return toString(DatePattern.NORM_TIME_FORMAT);
	}
1224771
public String getAsText() {
        DateTime value = (DateTime) getValue();
        return (value != null ? value.toString(this.formatter) : "");
    }
1285375
public static String selectJavaDateTimeFormatFromMomentJSFormatOrDefault(Locale locale, String momentJSFormat, boolean withDate, boolean withTime) {
		if (momentJSFormat == null) {
			String dateFormat = "";
			if (withDate) {
				dateFormat = ((SimpleDateFormat) DateFormat.getDateInstance(DateFormat.SHORT, locale)).toPattern();
			}
			String timeFormat = "";
			if (withTime) {
				timeFormat = ((SimpleDateFormat)DateFormat.getTimeInstance(DateFormat.MEDIUM, locale)).toPattern();
			}
			// Since DateFormat.SHORT is silly, return a smart format
			if (dateFormat.equals("M/d/yy")) {
				dateFormat = "MM/dd/yyyy";
			}
			else if (dateFormat.equals("d/M/yy")) {
				dateFormat = "dd/MM/yyyy";
			}
			return (dateFormat + " " + timeFormat).trim();
		} else {
			return LocaleUtils.momentToJavaFormat(momentJSFormat);
		}
	}
1220388
private function parseDateTimeFormat()
    {
        try {
            if ($this->isNull($this->format)) {
                $this->format = self::$defaultFormat;
            }

            $str = new StringObject($this->format);
            $chunks = $str->split();

            $this->buildFormatterList();

            foreach ($chunks as $c) {
                foreach (self::$formatters as $fk => $f) {
                    if ($f->inArray($c)) {
                        $this->dateTimeFormat[$fk] = $c;
                    }
                }
            }
            $this->dateTimeFormat = new ArrayObject($this->dateTimeFormat);
        } catch (\Exception $e) {
            throw new DateTimeObjectException(DateTimeObjectException::MSG_INVALID_DATE_FORMAT, [$this->format]);
        }
    }