2016-08-13 85 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也很有帮助,并给出了一些具体的例子。