/*
 * $Id$
 * $Revision$
 * $Date$
 *
 * ====================================================================
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package wicket.util.convert.converters;

import java.text.NumberFormat;
import java.util.Locale;

/**
 * Converts from Date to String.
 *
 * @author Eelco Hillenius
 */
public final class NumberToStringConverter extends AbstractConverter
{
	/** The date format to use */
    private NumberFormat numberFormat;
    
    /**
     * @see wicket.util.convert.converters.AbstractConverter#setLocale(java.util.Locale)
     */
    public void setLocale(Locale locale)
    {
        super.setLocale(locale);
        numberFormat = null;
    }
    
    /**
     * @return Returns the numberFormat.
     */
    public final NumberFormat getNumberFormat()
    {
        if (numberFormat == null && locale != null)
        {
            numberFormat = NumberFormat.getInstance(locale);
        }
        return numberFormat;
    }
    
    /**
     * @param numberFormat The numberFormat to set.
     */
    public final void setNumberFormat(final NumberFormat numberFormat)
    {
        this.numberFormat = numberFormat;
    }

	/**
	 * @see wicket.util.convert.ITypeConverter#convert(java.lang.Object)
	 */
	public Object convert(final Object value)
	{
        if (numberFormat != null)
        {
            return numberFormat.format(value);
        }
        return value.toString();
	}
}

@@ -796,17 +796,18 @@
 ring.%0A *
+ 
 %0A
-
  * @auth
@@ -931,20 +931,17 @@
  use */%0A
-    
+%09
 private 
@@ -967,33 +967,23 @@
 Format;%0A
-    %0A    /**%0A    
+%0A%09/**%0A%09
  * @see 
@@ -1059,28 +1059,22 @@
 Locale)%0A
-     */%0A    
+%09 */%0A%09
 public v
@@ -1102,30 +1102,21 @@
 locale)%0A
-    %7B%0A        
+%09%7B%0A%09%09
 super.se
@@ -1132,24 +1132,18 @@
 ocale);%0A
-        
+%09%09
 numberFo
@@ -1155,39 +1155,26 @@
 = null;%0A
-    %7D%0A    %0A    /**%0A    
+%09%7D%0A%0A%09/**%0A%09
  * @retu
@@ -1202,28 +1202,22 @@
 Format.%0A
-     */%0A    
+%09 */%0A%09
 public f
@@ -1252,30 +1252,21 @@
 ormat()%0A
-    %7B%0A        
+%09%7B%0A%09%09
 if (numb
@@ -1301,38 +1301,23 @@
 = null)%0A
-        %7B%0A            
+%09%09%7B%0A%09%09%09
 numberFo
@@ -1357,34 +1357,22 @@
 ocale);%0A
-        %7D%0A        
+%09%09%7D%0A%09%09
 return n
@@ -1388,31 +1388,18 @@
 at;%0A
-    %7D%0A    %0A    /**%0A    
+%09%7D%0A%0A%09/**%0A%09
  * @
@@ -1446,20 +1446,14 @@
 et.%0A
-     */%0A    
+%09 */%0A%09
 publ
@@ -1515,30 +1515,21 @@
 Format)%0A
-    %7B%0A        
+%09%7B%0A%09%09
 this.num
@@ -1554,20 +1554,17 @@
 Format;%0A
-    
+%09
 %7D%0A%0A%09/**%0A
@@ -1688,117 +1688,106 @@
 %0A%09%7B%0A
-        if (numberFormat != null)%0A        %7B%0A            return numberFormat.format(value);%0A        %7D%0A        
+%09%09NumberFormat fmt = getNumberFormat();%0A%09%09if (fmt != null)%0A%09%09%7B%0A%09%09%09return fmt.format(value);%0A%09%09%7D%0A%09%09
 retu

use numberformat