My task bar shows "Sat Feb 9, 5:41 PM". Where does Ubuntu store the current Date/Time format information? Is it retrievable?
I will be programming in Java, and would like to access the current format set by the user.
My task bar shows "Sat Feb 9, 5:41 PM". Where does Ubuntu store the current Date/Time format information? Is it retrievable?
I will be programming in Java, and would like to access the current format set by the user.
Java uses java.util.Locale
objects in most calls dealing with formatting output for the user. There is a default Locale (Locale.getDefault()
) which ought to be what the current user specified in the system settings. Otherwise you can use the LANGUAGE
or LANG
environment variables as input for new Locale(String)
.
Note that you can have specific locales for specific output:
LC_ADDRESS
LC_IDENTIFICATION
LC_MEASUREMENT
LC_MONETARY
LC_NAME
LC_NUMERIC
LC_PAPER
LC_TELEPHONE
LC_TIME
Yes, it is, with the command:
locale date_fmt
The output will look like:
%a %e %b %Y %k:%M:%S %Z
To see what it means:
date --help
I wouldn't be surprised if there existed a library in Java retrieving the info with a built in wrapper though instead of a system call.