JAVA date timezone 的用法

 Locale myLocale = Locale.getDefault();
    // Locale.setDefault(Locale.CHINA);
    // myLocale = Locale.getDefault();
     System.out.println(myLocale.getCountry());

     System.out.println(myLocale.getLanguage());

     System.out.println(myLocale.getDisplayCountry());

     System.out.println(myLocale.getDisplayLanguage());
    
     TimeZone localtime = TimeZone.getTimeZone("Asia/Shanghai");
     //TimeZone localtime = TimeZone.getTimeZone("Australia/Adelaide");
     System.out.println(localtime);
     TimeZone.setDefault(localtime);
    
     Calendar currentCal =Calendar.getInstance();
     System.out.println(currentCal.getTime());
     System.out.println(currentCal.get(Calendar.YEAR));
     System.out.println(currentCal.get(Calendar.DATE));
     System.out.println(currentCal.get(Calendar.MONTH));
     System.out.println(currentCal.get(Calendar.HOUR));
     System.out.println(currentCal.get(Calendar.MINUTE));
     System.out.println(currentCal.get(Calendar.SECOND));
     System.out.println(currentCal.get(Calendar.MILLISECOND));  

你可能感兴趣的:(JAVA date timezone 的用法)