0

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.

2
  • Hi Peter, just curious, but did you notice you've got answers? Curious if it works for you (any). Feb 12, 2019 at 9:52
  • @PeterStone what if the users uses clockoverride extension??
    – PRATAP
    Feb 13, 2019 at 9:12

2 Answers 2

0

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
0

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

See also here and here.

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .