Which Java library that returns the language of the computer? [closed]

-1
package horadosistema;

import java.util.Date;

public class HoraDoSistema {
 public static void main(String[] args) {
     Date relogio = new Date();

     System.out.println("A hora do sistema é");
     System.out.println(relogio.toString());
    }

}
    
asked by anonymous 27.08.2017 / 21:55

1 answer

2

Try to use the java.lang.System class:

System.getProperty("user.country");

Or try using java.util.Locale :

Locale currentLocale = Locale.getDefault();
currentLocale.getDisplayLanguage();

To recover the system date / time by using java.util.Date :

Date today = Calendar.getInstance().getTime();        
DateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
String todayStr = df.format(today);
    
27.08.2017 / 23:18