Example usage for java.util Locale toString

List of usage examples for java.util Locale toString

Introduction

In this page you can find the example usage for java.util Locale toString.

Prototype

@Override
public final String toString() 

Source Link

Document

Returns a string representation of this Locale object, consisting of language, country, variant, script, and extensions as below:
language + "_" + country + "_" + (variant + "_#" | "#") + script + "_" + extensions
Language is always lower case, country is always upper case, script is always title case, and extensions are always lower case.

Usage

From source file:com.google.code.gerrytan.jsonsimple.HomeController.java

/**
 * Simply selects the home view to render by returning its name.
 *///from  w  ww. jav  a2  s.c  o m
@RequestMapping(value = "/home", method = RequestMethod.GET)
public String home(Locale locale, Model model) {
    logger.info("Welcome home! the client locale is " + locale.toString());

    Date date = new Date();
    DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);

    String formattedDate = dateFormat.format(date);

    model.addAttribute("serverTime", formattedDate);

    return "home";
}

From source file:org.spo.ifs.template.web.AdminController.java

@RequestMapping(value = "/metrics", method = RequestMethod.GET)
public String metrics(Locale locale, Model model) {
    logger.info("Welcome home! the client locale is " + locale.toString());

    return "home";
}

From source file:au.com.redbarn.liferay.spring.mvc.portlet.HomeController.java

/**
 * Simply selects the home view to render by returning its name.
 *///from w w  w.j a  va 2s  .  co m
@RenderMapping
public String home(Locale locale, Model model) {

    log.info("Welcome home! the client locale is " + locale.toString());

    Date date = new Date();
    DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);

    String formattedDate = dateFormat.format(date);

    model.addAttribute("serverTime", formattedDate);

    return "home";
}

From source file:org.craftercms.engine.targeting.impl.LocaleTargetIdManager.java

@Override
public List<String> getAvailableTargetIds() {
    String[] availableTargetIds = SiteProperties.getAvailableTargetIds();
    if (ArrayUtils.isEmpty(availableTargetIds)) {
        List<Locale> availableLocales = LocaleUtils.availableLocaleList();
        List<String> availableLocaleStrs = new ArrayList<>(availableLocales.size());

        for (Locale locale : availableLocales) {
            String localeStr = locale.toString();
            // Ignore empty ROOT locale
            if (StringUtils.isNotEmpty(localeStr)) {
                availableLocaleStrs.add(StringUtils.lowerCase(localeStr));
            }// w  w  w.j  a v  a2  s . c  o m
        }

        return availableLocaleStrs;
    } else {
        return Arrays.asList(availableTargetIds);
    }
}

From source file:org.jasig.portlet.cms.mvc.portlet.ViewContentController.java

/**
 * Get the configured user-facing content for this portlet configuration.
 * /*from ww w.  j  ava  2 s  .  c om*/
 * @param request
 * @return
 */
@ModelAttribute("content")
public String getContent(PortletRequest request) {
    Locale locale = request.getLocale();
    return this.contentDao.getContent(request, locale.toString());
}

From source file:net.jawr.web.resource.bundle.locale.SpringLocaleResolver.java

public String resolveLocaleCode(HttpServletRequest request) {
    org.springframework.web.servlet.LocaleResolver resolver = RequestContextUtils.getLocaleResolver(request);
    Locale resolved = resolver.resolveLocale(request);
    if (resolved != Locale.getDefault())
        return resolved.toString();
    else//from   w w w.j  ava2  s  . c  o  m
        return null;
}

From source file:au.com.redbarn.liferay.portlet.property.HomeController.java

/**
 * Simply selects the home view to render by returning its name.
 *///from  w ww.  j  a  va2s  .co m
@RenderMapping
public String home(RenderRequest request, Locale locale, Model model) {

    log.info("Welcome home! the client locale is " + locale.toString());

    model.addAttribute(Constants.MESSAGE_PARAM,
            request.getPreferences().getValue(Constants.MESSAGE_PARAM, Constants.DEFAULT_MESSAGE));

    Date date = new Date();
    DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);

    String formattedDate = dateFormat.format(date);

    model.addAttribute("serverTime", formattedDate);

    return "home";
}

From source file:au.com.redbarn.liferay.spring.mvc.portlet.controller.HomeController.java

/**
 * Simply selects the home view to render by returning its name.
 *///from  w w  w .j  av  a2  s. co m
@RenderMapping
public String home(Locale locale, Model model) {

    logger.info("Welcome home! the client locale is " + locale.toString());

    model.addAttribute("message", homeService.getMessage());
    model.addAttribute("bandwidthHog", homeService.getBandwithHog());
    model.addAttribute("serverTime", homeService.getFormattedDate(locale));
    model.addAttribute("uptime", homeService.getUptime());
    model.addAttribute("defaultCompanyId", homeService.getDefaultCompanyId());

    return "home";
}

From source file:com.fredhopper.core.connector.index.generate.writer.VariantCsvWriter.java

@Override
public void print(final FhVariantData source) throws IOException {

    Preconditions.checkArgument(source != null);
    Preconditions.checkArgument(!CollectionUtils.isEmpty(source.getLocales()));

    for (final Locale locale : source.getLocales()) {
        printLine(source.getVariantId(), source.getProductId(), locale.toString());
    }/*from   ww w .ja  v a2  s. c o  m*/
}

From source file:com.tcloud.bee.key.server.mvc.controller.HomeController.java

/**
 * Simple controller for "/" that returns a Thymeleaf view.
 *///  w  w  w  .j a  v  a  2  s.  c o  m
@RequestMapping(value = "/", method = RequestMethod.GET)
public String home(Locale locale, Model model) {
    logger.info("Welcome home! the client locale is " + locale.toString());

    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    logger.trace("Authentication principal: {}", auth.getPrincipal());
    logger.trace("Authentication name: {}", auth.getName());

    Date date = new Date();
    DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);

    String formattedDate = dateFormat.format(date);

    model.addAttribute("serverTime", formattedDate);
    // model.addAttribute("echoService", echoService);
    model.addAttribute("someItems", new String[] { "one", "two", "three" });

    return "home";
}