2012-03-28 12 views
4

フランス語で日付を印刷したいと思います。 たとえば「Janvier」ではなく「January」ではありません。日付の言語

SimpleDateFormat mDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss",Locale.FRENCH); 
Date date = null; 
      try { 
       date = mDateFormat.parse(document.date); 
      } catch (ParseException e) { 
       // TODO Auto-generated catch block 
       e.printStackTrace(); 
      } 

をしかし、それは動作しません:

私はこれを使用しています!

どのように私はこれを行うことができますか?

答えて

9

public class FormatDateLocale { 
    public static void main(String[] args) { 
     // 
     // Defines an array of Locale we are going to use for 
     // formatting date information. 
     // 
     Locale[] locales = new Locale[] { 
       Locale.JAPAN, 
       Locale.CHINA, 
       Locale.KOREA, 
       Locale.TAIWAN, 
       Locale.ITALY, 
       Locale.FRANCE, 
       Locale.GERMAN 
     }; 

     // Get an instance of current date time 
     Date today = new Date(); 

     // 
     // Iterates the entire Locale defined above and create a long 
     // formatted date using the SimpleDateFormat.getDateInstance() 
     // with the format, the Locale and the date information. 
     // 
     for (Locale locale : locales) { 
      System.out.println("Date format in " 
       + locale.getDisplayName() 
       + " = " 
       + SimpleDateFormat.getDateInstance(
         SimpleDateFormat.LONG, locale) 
          .format(today).toUpperCase()); 
     } 
    } 
} 

我々のコードの結果はある...これを試してみてください:

Date format in Japanese (Japan) = 2009/01/04 
Date format in Chinese (China) = 2009年1月4日 
Date format in Korean (South Korea) = 2009년 1월 4일 (일) 
Date format in Chinese (Taiwan) = 2009年1月4日 
Date format in Italian (Italy) = 4 GENNAIO 2009 
Date format in French (France) = 4 JANVIER 2009 
Date format in German = 4. JANUAR 2009 

ソースリンク:http://www.kodejava.org/examples/415.html

+0

その作業は、どうもありがとうございました –