Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0
* http://www.apache.org/licenses/LICENSE-2.0 */
package net.sf.mmm.util.nls.impl.formatter;
import java.io.IOException;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.Format;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import net.sf.mmm.util.date.api.Iso8601Util;
import net.sf.mmm.util.lang.api.Formatter;
import net.sf.mmm.util.lang.base.AbstractFormatter;
import net.sf.mmm.util.nls.api.NlsFormatterManager;
/**
* This class provides {@link Formatter}s for various types. It contains the formatting logic for various
* implementations of {@link net.sf.mmm.util.nls.base.SimpleNlsFormatter}. This way it is easier to maintain
* GWT compatibility by replacing this class.
*
* @author Joerg Hohwiller (hohwille at users.sourceforge.net)
* @since 3.0.0
*/
public final class FormatterProvider {
/**
* Construction prohibited.
*/
private FormatterProvider() {
super();
}
/**
* This method converts the given {@link net.sf.mmm.util.nls.api.NlsFormatterPlugin#getStyle() style} to the
* according {@link DateFormat}-style constant.
*
* @param style is the {@link net.sf.mmm.util.nls.api.NlsFormatterPlugin#getStyle() style} to convert.
* @return the according {@link DateFormat}-style constant (e.g. {@link DateFormat#MEDIUM}).
*/
private static int convertStyle(String style) {
if (style.equals(NlsFormatterManager.STYLE_SHORT)) {
return DateFormat.SHORT;
} else if (style.equals(NlsFormatterManager.STYLE_LONG)) {
return DateFormat.LONG;
} else if (style.equals(NlsFormatterManager.STYLE_MEDIUM)) {
return DateFormat.MEDIUM;
} else if (style.equals(NlsFormatterManager.STYLE_FULL)) {
return DateFormat.FULL;
} else {
throw new IllegalArgumentException(style);
}
}
/**
* @param locale is the {@link Locale}.
* @param type is the {@link net.sf.mmm.util.nls.api.NlsFormatterPlugin#getType() type} (must be one of
* {@link NlsFormatterManager#TYPE_DATE}, {@link NlsFormatterManager#TYPE_TIME},
* {@link NlsFormatterManager#TYPE_DATETIME}).
* @param style is the {@link net.sf.mmm.util.nls.api.NlsFormatterPlugin#getStyle() style}.
* @return the {@link FormatterProvider} for {@link Integer}.
*/
public static Formatter