Guest

Nigel Wade wrote:
> wrote:
>
>> I want to get local Date from windows. this date depends on what
>> windows is installed(English, German).
>> For Example: English windows time: 3/18/08 9:21 AM
>
> That would be American format, we English prefer our dates in sequential order
> rather than inside-out order.
>
>> German windows time: 18.03.08 09:22
>>
>> How can I get this Date?
>
> Use DateFormat and Local.
^^^^^
Locale, as in java.util.Locale.

Actually /getting/ the date from Windows does not involve formats - you're
reading an integral quantity from the system clock. Time zones remain an
issue, but string formats are completely irrelevant.

/Displaying/ the date according to locale, or parsing a string that represents
a date, use the advice Nigel and others gave.

wrote:
> but i need also to have the time 09:22 not only date 18.03.08...

Read the docs. You have to be able to learn some things on your own - in this
case it's like asking for directions to the gas station that's a quarter mile
from the off-ramp after Nigel told you which exit to take off the highway.

He told you he left it "as an exercise for the student" - you don't want to
miss out on your exercise. It's good for your health.

Guest

Lew wrote:
> Nigel Wade wrote:
>> wrote:
>>
>>> I want to get local Date from windows. this date depends on what
>>> windows is installed(English, German).
>>> For Example: English windows time: 3/18/08 9:21 AM
>>
>> That would be American format, we English prefer our dates in sequential
order
>> rather than inside-out order.
>>
>>> German windows time: 18.03.08 09:22
>>>
>>> How can I get this Date?
>>
>> Use DateFormat and Local.
> ^^^^^
> Locale, as in java.util.Locale.
>

On Tue, 18 Mar 2008 11:57:12 +0000, Nigel Wade <>
wrote, quoted or indirectly quoted someone who said :
>That would be American format, we English prefer our dates in sequential order
>rather than inside-out order.

ISO dates are yyyy-mm-dd

Given that almost everything you write now adays could potentially be
read by people anywhere in the world, it seems to me we would should
be avoiding national date formats and using ISO.

National dates in isolation are ambiguous. They might be dd-mm or
mm-dd. ISO date format thankfully is still unambiguous.
--

Roedy Green wrote:
> On Tue, 18 Mar 2008 11:57:12 +0000, Nigel Wade <>
> wrote, quoted or indirectly quoted someone who said :
>
>>That would be American format, we English prefer our dates in sequential order
>>rather than inside-out order.
>
> ISO dates are yyyy-mm-dd
>
> Given that almost everything you write now adays could potentially be
> read by people anywhere in the world, it seems to me we would should
> be avoiding national date formats and using ISO.
>
> National dates in isolation are ambiguous.

Indeed. Trying to decide exactly what is meant by a date of the format 2/3/2008
is a big problem. Good software will use the locale, bad software will hardcode
the programmer's idea of the locale. But which did any particular piece of
software actually use?

One of the worst culprits I have to deal with is Veritas NetBackup, a rather
expensive enterprise backup system. Because it's American software all dates
are output in US format, even though the GUI interface is written in Java. It
must have taken them more work to hardcode the output format specifiers to US
than it would have done to use a Locale and its date formatters.

If one knows the string to be an ISO date, it is unambiguous. Extended
format - yyyy-mm-dd - could be an arithmetic expression. And it should
not be assumed that a date such as 20080305 is ISO Basic format (try
Google for that string).

In comp.lang.java.programmer message <froonh$ang$>,
Tue, 18 Mar 2008 15:56:33, Nigel Wade <> posted:
>Indeed. Trying to decide exactly what is meant by a date of the format 2/3/2008
>is a big problem. Good software will use the locale, bad software will hardcode
>the programmer's idea of the locale.

Good software will use either the locale or the ISO form for human I/O.

But, for communicating with other systems elsewhere, good software will
use a fixed, agreed, and preferably ISO format.

Nowadays, too, a single locale may not suit a given user (Locale was
probably introduced on the basis that people all use the same system
mm/dd/yy hh:mm am, except for foreigners).

But, hereabouts, while almost everyone uses GMT in winter and BST in
summer, hence the "proper" chronological locale, a very large proportion
would probably prefer Korean locale otherwise.

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!