Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6860289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:23:25+00:00 2026-05-27T02:23:25+00:00

I want to create a java.util.Locale object using the display name of the locale.

  • 0

I want to create a java.util.Locale object using the display name of the locale. For example, i want the locale of thailand having the value

th_TH

if the display name is

Thai (Thailand)

How to do this?

One way i could think of is to iterate in all the available locales and comparing the display name of each locale with my display name and finding the locale object. But i want to know if there is any smarter way available for this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T02:23:26+00:00Added an answer on May 27, 2026 at 2:23 am

    If all you have to go on is a display name string, then comparing with display names of available locales is all you can do.

    If you will be performing the operation multiple times, then it makes sense to build a Map of locales by display name once and then using that to answer your queries.

    Could the display name be in more that one language. For example, could the display name be in French – thaï (Thaïlande)?

    If so, you need to do a double loop to query for local display names. In the outer loop, you need to use all locales the language of which may be used to supply a display name.

    Here is an example in which the display name may be in the language of any supported locale:

        Map<String,Locale> locales = new HashMap<String,Locale>();
        for (Locale l1: Locale.getAvailableLocales()) {
            for (Locale l2: Locale.getAvailableLocales()) {
                locales.put(l2.getDisplayName(l1), l2);
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using java.util logging classes to create a rolling file appender. I want
I want to create a Java application bundle for Mac without using Mac. According
I want to create a Producer that makes it possible to inject a java.util.ResourceBundle
I want to create and publish simple WebService using Java. Everything compiles. When I
I want to give an example. import java.util.Scanner; public class ana { public static
I need to create a java.util.Date object with an Australian timezone. this object is
I create a java.util.concurrent.locks.ReentrantReadWriteLock using new java.util.concurrent.locks.ReentrantReadWriteLock().readLock() and then I pass to a method
I want to create a Java Desktop Application and want to employ some mechanism
I want create a excel with Apache POI in java and I must insert
I want to create registry key through java program to add the jar file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.