/*
 * jETeL/CloverETL - Java based ETL application framework.
 * Copyright (c) Javlin, a.s. (info@cloveretl.com)
 *  
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */
package org.jetel.util.formatter;

import java.util.Locale;

import org.jetel.data.Defaults;
import org.jetel.metadata.DataFieldFormatType;
import org.jetel.util.MiscUtils;
import org.jetel.util.string.StringUtils;

/**
 * Factory for internally used date formatters.
 *
 * @author Martin Janik, Javlin a.s. &lt;martin.janik@javlin.eu&gt;
 * @author David Pavlis, Javlin a.s. &lt;david.pavlis@javlin.eu&gt;
 *
 * @version 16th April 2010
 * @created 17th August 2009
 */
public final class DateFormatterFactory {


	public static DateFormatter getFormatter(String formatString, Locale locale) {
		if (locale == null) {
			locale = MiscUtils.createLocale(Defaults.DEFAULT_LOCALE);
		}

		if (StringUtils.isEmpty(formatString)) {
			return new JavaDateFormatter(locale);
		} else if (DataFieldFormatType.getFormatType(formatString) == DataFieldFormatType.JODA) {
			return new JodaDateFormatter(DataFieldFormatType.JODA.getFormat(formatString), locale);
		} else {
			if (DataFieldFormatType.getFormatType(formatString) == DataFieldFormatType.JAVA) {
				formatString = DataFieldFormatType.JAVA.getFormat(formatString);
			}

			return new JavaDateFormatter(locale);
		}
	}

	public static DateFormatter getFormatter(String formatString, String localeString) {
		return getFormatter(formatString, MiscUtils.createLocale(localeString));
	}

	public static DateFormatter getFormatter(String formatString) {
		return getFormatter(formatString, (Locale) null);
	}

	public static DateFormatter getFormatter(Locale locale) {
		return new JavaDateFormatter(locale);
	}

	public static DateFormatter getFormatter() {
		return new JavaDateFormatter();
	}

	private DateFormatterFactory() {
		throw new UnsupportedOperationException();
	}

}

@@ -1997,32 +1997,46 @@
 vaDateFormatter(
+formatString, 
 locale);%0A%09%09%7D%0A%09%7D%0A

fix of previous commit "DataFieldMetadata.format has new 'prefix' syntax - all related code have to be re-factored."