Skip to content

Source code

Ken Kousen edited this page Oct 7, 2018 · 4 revisions

Selected source code examples

MyBean.java
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;

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

@Configuration
public class MyBeans {
    @Bean
    public NumberFormat defaultCurrencyFormatter() {
        return NumberFormat.getCurrencyInstance();
    }

    @Bean @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
    public NumberFormat deCurrencyFormatter() {
        return NumberFormat.getCurrencyInstance(Locale.GERMANY);
    }
}

Clone this wiki locally