Example usage for java.text NumberFormat getCurrency

List of usage examples for java.text NumberFormat getCurrency

Introduction

In this page you can find the example usage for java.text NumberFormat getCurrency.

Prototype

public Currency getCurrency() 

Source Link

Document

Gets the currency used by this number format when formatting currency values.

Usage

From source file:Main.java

public static void main(String[] args) throws Exception {
    NumberFormat numberFormat = NumberFormat.getInstance();
    System.out.println(numberFormat.getCurrency().getDisplayName());
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    NumberFormat numberFormat = NumberFormat.getCurrencyInstance();
    System.out.println(numberFormat.getCurrency().getDisplayName());
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    NumberFormat numberFormat = NumberFormat.getCurrencyInstance(Locale.CANADA);
    System.out.println(numberFormat.getCurrency().getDisplayName());
}

From source file:com.concursive.connect.web.modules.login.utils.UserUtils.java

public static User createGuestUser() {
    User user = new User();
    user.setId(-2);/*from ww  w .java 2  s .co  m*/
    user.setIdRange("-2");
    user.setGroupId(1);
    user.setFirstName("Guest");
    user.setEnabled(true);
    // @todo Use applicationPrefs for the correct defaults
    // Set a default time zone for user
    if (user.getTimeZone() == null) {
        user.setTimeZone(TimeZone.getDefault().getID());
    }
    // Set a default currency for user
    if (user.getCurrency() == null) {
        user.setCurrency(NumberFormat.getCurrencyInstance().getCurrency().getCurrencyCode());
    }
    // Set default locale: language, country
    if (user.getLanguage() == null) {
        user.setLanguage("en_US");
    }
    return user;
}

From source file:com.concursive.connect.config.ApplicationPrefs.java

/**
 * Description of the Method//w w  w . j a  v a2s .  c o m
 *
 * @param context Description of the Parameter
 */
public void configureDefaultBehavior(ServletContext context) {
    LOG.info("Configuring default behavior...");
    // Default login and session validation
    if (!this.has(LOGIN_MODE)) {
        this.add(LOGIN_MODE, "Default");
    }
    // Detect if this instance is using a legacy default, and upgrade to a theme
    if (!this.has(THEME)) {
        if (!this.has(JSP_TEMPLATE) || "/layoutDefault.jsp".equals(this.get(JSP_TEMPLATE))) {
            this.add(THEME, "default");
            this.add(COLOR_SCHEME, "dark_blue");
        }
    }

    // Determine the site theme
    if (this.has(THEME)) {
        // Use a theme and its color scheme; always use the default if the theme is missing
        String theme = "default";
        String colorScheme = "dark_blue";
        Set<String> themeFiles = context.getResourcePaths("/themes/" + this.get(THEME) + "/color-schemes");
        if (themeFiles != null && themeFiles.size() > 0) {
            for (String thisFile : themeFiles) {
                if (thisFile.startsWith(
                        "/themes/" + this.get(THEME) + "/color-schemes/" + this.get(COLOR_SCHEME))) {
                    theme = this.get(THEME);
                    colorScheme = this.get(COLOR_SCHEME);
                }
            }
        }
        if (!theme.equals(get(THEME))) {
            LOG.error("The theme (" + get(THEME) + ") and color scheme (" + get(COLOR_SCHEME)
                    + ") could not be found, using default theme");
        }
        addParameter(context, Constants.TEMPLATE_THEME, theme);
        addParameter(context, Constants.TEMPLATE_COLOR_SCHEME, colorScheme);
        // Determine the layout (or use the default layout)
        String layout = "default";
        Set<String> layoutFiles = context.getResourcePaths("/themes/" + this.get(THEME) + "/jsp/");
        if (layoutFiles != null && layoutFiles.size() > 0) {
            for (String thisFile : layoutFiles) {
                if (("/themes/" + this.get(THEME) + "/jsp/layout.jsp").equals(thisFile)) {
                    layout = this.get(THEME);
                }
            }
        }
        if ("default".equals(layout) && !"default".equals(this.get(THEME))) {
            try {
                // Check for a compiled layout
                Class.forName("org.apache.jsp.themes." + JspUtils.makeJavaIdentifier(this.get(THEME))
                        + ".jsp.layout_jsp");
                layout = this.get(THEME);
            } catch (Exception e) {
                LOG.info("Using default theme: " + e.getMessage());
            }
        }
        addParameter(context, Constants.TEMPLATE_LAYOUT, "/themes/" + layout + "/jsp/layout.jsp");
        LOG.info("THEME: " + get(THEME));
        LOG.info("  COLOR SCHEME: " + get(COLOR_SCHEME));
        LOG.info("  LAYOUT: " + "/themes/" + layout + "/jsp/layout.jsp");
    } else {
        // Use the specified template
        addParameter(context, Constants.TEMPLATE_LAYOUT, this.get(JSP_TEMPLATE));
        // Default CSS for all items on page
        addParameter(context, Constants.TEMPLATE_CSS, this.get(CSS_FILE));
    }

    // Default color scheme for themeable items (deprecated)
    if (this.has("SKIN")) {
        addParameter(context, "SKIN", this.get("SKIN"));
    } else {
        addParameter(context, "SKIN", "blue");
        this.add("SKIN", "blue");
    }

    // Application Settings
    if (!this.has(USERS_CAN_REGISTER)) {
        this.add(USERS_CAN_REGISTER, "true");
    }
    if (!this.has(USERS_CAN_INVITE)) {
        this.add(USERS_CAN_INVITE, "true");
    }
    if (!this.has(SHOW_TERMS_AND_CONDITIONS)) {
        this.add(SHOW_TERMS_AND_CONDITIONS, "true");
    }
    if (!this.has(USERS_CAN_START_PROJECTS)) {
        this.add(USERS_CAN_START_PROJECTS, "false");
    }
    if (!this.has(USERS_ARE_ANONYMOUS)) {
        this.add(USERS_ARE_ANONYMOUS, "false");
    }
    if (!this.has(SEARCH_USES_LOCATION)) {
        this.add(SEARCH_USES_LOCATION, "true");
    }
    if (!this.has(SHOW_HOLIDAYS)) {
        this.add(SHOW_HOLIDAYS, "true");
    }

    // Portal
    if (!this.has(HOME_URL)) {
        this.add(HOME_URL, "index.shtml");
    } else if ("Portal.do?command=Default".equals(this.get(HOME_URL))) {
        this.add(HOME_URL, "index.shtml");
    }
    if (!this.has("PORTAL")) {
        this.add("PORTAL", "true");
    }
    if (!this.has(WEB_PAGE_TITLE)) {
        this.add(WEB_PAGE_TITLE, ApplicationVersion.TITLE);
    }
    if (!this.has(LANGUAGE)) {
        this.add(LANGUAGE, "en_US");
    }
    if (!this.has(TIMEZONE)) {
        this.add(TIMEZONE, TimeZone.getDefault().getID());
    }
    if (!this.has(CURRENCY)) {
        this.add(CURRENCY, NumberFormat.getCurrencyInstance().getCurrency().getCurrencyCode());
    }
    if (!this.has(LANGUAGES_SUPPORTED)) {
        this.add(LANGUAGES_SUPPORTED, "en_US");
    }
    if (!this.has(MAIN_PROFILE)) {
        this.add(MAIN_PROFILE, "main-profile");
    }

    // Dimdim service
    if (!this.has(DIMDIM_ENABLED)) {
        this.add(DIMDIM_ENABLED, "false");
    }
    if (!this.has(DIMDIM_API_DOMAIN)) {
        // @note Dimdim public API is no longer available
        //this.add(DIMDIM_API_DOMAIN, "http://webmeeting.dimdim.com/portal");
    }
}