<commit_before><@header?interpret />
package ${project_namespace}.harmony.util;

import java.text.ParseException;

import org.joda.time.DateTime;
import org.joda.time.LocalDateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.ISODateTimeFormat;

import android.util.Log;

import ${project_namespace}.${project_name?cap_first}Application;

/** Utils for date manipulation. */
public class DateUtils extends android.text.format.DateUtils {
	/** TAG for debug purpose. */
	private static final String TAG = "DateUtils";

	/** Internal pattern for AM PM time. */
	private static final String TIME_AMPM_PATTERN = "hh:mm a";
	/** Internal pattern for H24 time. */
	private static final String TIME_24H_PATTERN = "HH:mm";

	/** Time Format type. */
	public enum TimeFormatType {
		/** 24h format. */
		H24,
		/** AM/PM format. */
		AMPM,
		/** Format defined in user's Android configuration. */
		ANDROID_CONF;
	}


	/**
	 * Convert date to Android string date format.
	 * @param date to convert
	 * @return string date with Android date format
	 */
	public static String formatDateToString(DateTime date) {
		return ${project_name?cap_first}Application.getDateFormat()
														 .format(date.toDate());
	}

	/**
	 * Convert date to Android string time format.
	 * @param time Time to convert
	 * @return string time with Android time format
	 */
	public static String formatTimeToString(DateTime time) {
		String result = null;
		if (${project_name?cap_first}Application.is24Hour()) {
			result = time.toString(
					DateTimeFormat.forPattern(TIME_24H_PATTERN));
		} else {
			result = time.toString(
					DateTimeFormat.forPattern(TIME_AMPM_PATTERN));
		}

		return result;
	}

	/**
	 * Convert date to Android string time format.
	 * @param time to convert
	 * @param formatType The time format
	 * @return string time with Android time format
	 */
	public static String formatTimeToString(
			DateTime time,
			TimeFormatType formatType) {
		String result;
		if (formatType.equals(TimeFormatType.H24)) {<commit_msg>Fix #2970<commit_after><@header?interpret />
package ${project_namespace}.harmony.util;

import java.text.ParseException;

import org.joda.time.DateTime;
import org.joda.time.LocalDateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.ISODateTimeFormat;

import android.util.Log;

import ${project_namespace}.${project_name?cap_first}Application;

/** Utils for date manipulation. */
public class DateUtils extends android.text.format.DateUtils {
	/** TAG for debug purpose. */
	private static final String TAG = "DateUtils";

	/** Internal pattern for AM PM time. */
	private static final String TIME_AMPM_PATTERN = "hh:mm a";
	/** Internal pattern for H24 time. */
	private static final String TIME_24H_PATTERN = "HH:mm";

	/** Time Format type. */
	public enum TimeFormatType {
		/** 24h format. */
		H24,
		/** AM/PM format. */
		AMPM,
		/** Format defined in user's Android configuration. */
		ANDROID_CONF;
	}


	/**
	 * Convert date to Android string date format.
	 * @param date to convert
	 * @return string date with Android date format
	 */
	public static String formatDateToString(DateTime date) { 
		TimeZone tz = date.getZone().toTimeZone();
		java.text.DateFormat df = ${project_name?cap_first}Application.getDateFormat();
		
		df.setTimeZone(tz);

		return df.format(date.toDate());
	}

	/**
	 * Convert date to Android string time format.
	 * @param time Time to convert
	 * @return string time with Android time format
	 */
	public static String formatTimeToString(DateTime time) {
		String result = null;
		if (${project_name?cap_first}Application.is24Hour()) {
			result = time.toString(
					DateTimeFormat.forPattern(TIME_24H_PATTERN));
		} else {
			result = time.toString(
					DateTimeFormat.forPattern(TIME_AMPM_PATTERN));
		}

		return result;
	}

	/**
	 * Convert date to Android string time format.
	 * @param time to convert
	 * @param formatType The time format
	 * @return string time with Android time format
	 */
	public static String formatTimeToString(
			DateTime time,
			TimeFormatType formatType) {
		String result;
		if (formatType.equals(TimeFormatType.H24)) {
{'fraction_non_alphanumeric': 0.1099664590321035, 'fraction_numerical': 0.007666506947771922, 'mean_word_length': 3.9291617473435654, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2487191', 'n_tokens_mistral': 1376, 'n_tokens_neox': 1219, 'n_words': 363}