⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 localedemo.java

📁 本java源程序包括了大量的学习程序(共27章)方便大家学习
💻 JAVA
字号:
import java.util.*;
public class LocaleDemo 
{
	Locale locale1,locale2;
	public LocaleDemo()
	{
		//返回默认的Locale对象为本地地区(以执行本程序的机器为准) 
		locale1 = Locale.getDefault();
		
		//设置locale2对象为美国地区
		locale2 = new Locale("en","US");
		
		//获取本地计算机信息
		String displayName1 = locale1.getDisplayCountry();
		String language1 = locale1.getLanguage();
		String country1 = locale1.getCountry();
		String displayCountry1 = locale1.getDisplayCountry();
		String variant1 = locale1.getVariant();
		String displayVariant1 = locale1.getDisplayVariant();
		
		//获取指定区域的信息
		String displayName2 = locale2.getDisplayCountry();
		String language2 = locale2.getLanguage();
		String country2 = locale2.getCountry();
		String displayCountry2 = locale2.getDisplayCountry();
		String variant2 = locale2.getVariant();
		String displayVariant2 = locale2.getDisplayVariant();	
		
		//显示本地信息
		System.out.println(locale1.toString());
		System.out.println(displayName1);
		System.out.println(language1);
		System.out.println(country1);
		System.out.println(displayCountry1);
		System.out.println(variant1);
		System.out.println(displayVariant1+"\n");
		
		//显示制定地区信息
		System.out.println(locale2.toString());
		System.out.println(displayName2);
		System.out.println(language2);
		System.out.println(country2);
		System.out.println(displayCountry2);
		System.out.println(variant2);
		System.out.println(displayVariant2);		
	}
	
	public static void main(String[] args) 
	{
		LocaleDemo localeDemo = new LocaleDemo();
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -