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

📄 internationalizationtest.java

📁 java 完全探索的随书源码
💻 JAVA
字号:
import java.util.*;import java.lang.*;import java.text.DateFormat;class InternationalizationTest extends Object{  public static void main(String args[])  {    // Declare variables to hold the three parameters    String lang = "";    String country = "";    String variant = "";    // Make sure the user passes the language variable on the command line    if ( args.length == 0 )    {      System.out.println("You must specify at least one parameter");      System.exit(1);    }    int argsSize = args.length;    // There was at least the language passed in    lang = args[0];    // Need to check the other two to see if they were passed in    if ( argsSize > 1 )      country = args[1];    if ( argsSize > 2 )      variant = args[2];    // Get the locale for the specific locale variables    Locale locale = new Locale( lang, country, variant );    // Get the Default Locale    Locale defaultLocale = Locale.getDefault();    // Print out the Locale information to the console    System.out.println( "Default Locale is: "+ defaultLocale.getDisplayName() );    System.out.println("You have selected Locale: "+ locale.getDisplayName() );    System.out.println("Default language, localized for your locale is: " +            defaultLocale.getDisplayLanguage( locale ) );    System.out.println("Default country name, localized: " + defaultLocale.getDisplayCountry( locale ) );    // Get a resource bundle based on the passed in locale    ResourceBundle bundle = null;    try    {      bundle = ResourceBundle.getBundle( "TestBundle", locale );      System.out.println( "Resources available are: ");      System.out.println("OK Label: " + bundle.getString("OK_LABEL") );      System.out.println("Cancel Label: " + bundle.getString("CANCEL_LABEL") );    }    catch( MissingResourceException e)    {      System.out.println( "No resources available for that locale." );    }    // Display date and time information based on the locale instance    DateFormat myFormat = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL, locale);    Calendar myCalendar = Calendar.getInstance( locale );    System.out.println("The localized date and time is: " +  myFormat.format( myCalendar.getTime() ) );   }}

⌨️ 快捷键说明

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