<commit_before>package org.nudge.elasticstack;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Utility class for the connector.
 */
public class Utils {

	private static final String ES_DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSZ";
	private static final String INDEX_SUFFIX_FMT = "yyyy-MM-dd";

	private static final ThreadLocal<DateFormat> df = new ThreadLocal<>();

	private Utils() {
	}

	public static String formatTimeToString(long timestamp) {
		df.set(new SimpleDateFormat(ES_DATE_FORMAT));
		return df.get().format(timestamp);
	}

	public static String getIndexSuffix() {
		df.set(new SimpleDateFormat(INDEX_SUFFIX_FMT));
		return df.get().format(new Date());
	}


}<commit_msg>avoid useless DateFormat creation<commit_after>package org.nudge.elasticstack;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Utility class for the connector.
 */
public class Utils {

	private static final String ES_DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSZ";
	private static final String INDEX_SUFFIX_FMT = "yyyy-MM-dd";

	private static final ThreadLocal<DateFormat> indexf = new ThreadLocal<>();
	private static final ThreadLocal<DateFormat> timef = new ThreadLocal<>();

	private Utils() {
	}

	public static String formatTimeToString(long timestamp) {
		DateFormat sdf = timef.get();
		if (sdf == null) {
			sdf = new SimpleDateFormat(ES_DATE_FORMAT);
			timef.set(sdf);
		}
		return sdf.format(timestamp);
	}

	public static String getIndexSuffix() {
		DateFormat sdf = indexf.get();
		if (sdf == null) {
			sdf = new SimpleDateFormat(INDEX_SUFFIX_FMT);
			indexf.set(sdf);
		}
		return sdf.format(new Date());
	}

}
{'fraction_non_alphanumeric': 0.12089201877934272, 'fraction_numerical': 0.0, 'mean_word_length': 4.799319727891157, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1683787', 'n_tokens_mistral': 604, 'n_tokens_neox': 562, 'n_words': 136}