2016-08-13 39 views
0
private void updateClock() { 
     SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd"); 
     Date d = new Date(); 
     day.setText(sdf.format(d)); 
     clock.setText(String.format("%tR", System.currentTimeMillis())); 
     if (RS != null) { 
      if (RS.adDue()) createAd(); 
     } 
    } 

如何將國際化應用於此以消除語言障礙?如何通過國際化顯示時間和日期?

回答

0

看看this page

你應該能夠沿着線做一些事情:

Locale currentLocale = new Locale("en", "US"); 
SimpleDateFormat sdf = new SimpleDatFormat("EEE MMM dd", currentLocale); 

或:

Locale currentLocale = new Locale("fr", "CA"); 
SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd", currentLocale); 

你可以找到關於不同支持的語言環境here更多信息。確保你導入java.util.Locale

編輯:This page也很有幫助,並給出了一些具體的例子。