Which Java library returns the computer language?

Asked

Viewed 3,501 times

-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());
    }

}
  • The question says "system language", but the code picks up the date, your question does not make much sense. Edit it and explain your doubt better.

  • "system system"

  • What does this code have to do with the title of the question?

1 answer

2

Try to use the class java.lang.System:

System.getProperty("user.country");

Or try to use the java.util.Locale:

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

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

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.