Locale problems in 1.4.1_03-b02

0 views
Skip to first unread message

JMM

unread,
Aug 24, 2004, 11:16:19 AM8/24/04
to
I'm having issues dealing with Locale under 1.4.1_03-b02. The problem
seems to be with the Java Runtime having problems reading the system
locale. My system locale is set to UK, but when I run a test program
(code below) I get the date formatted to a US locale instead of UK. I
ran the same program under 1.4.2_03 on win xp, and 1.4.2_04-b05 on
win2k which both worked fine. Running the same program under 1.4.1_03
on win xp and win 2k results in the problem. Does anyone know of a
workaround to this problem without upgrading to 1.4.2_03 or higher?
Also does anyone know what the minimum version we should have if we
did decide to upgrade JRE's?

Thanks,

Jonathan


import java.util.*;
import java.text.*;

public class LocaleTest
{
public static void main(String[] args)
{
DateFormat format = DateFormat.getDateInstanc(DateFormat.SHORT);
format.setCalendar(Calendar.getInstance());
format.getCalendar().set(Calendar.MILLISECOND,0);
format.getCalendar().set(Calendar.SECOND,0);
format.getCalendar().set(Calendar.MINUTE,0);
format.getCalendar().set(Calendar.HOUR,0);
System.out.println("date is "+
format.format(format.getCalendar().getTime()));
}
}

zoopy

unread,
Aug 24, 2004, 2:17:31 PM8/24/04
to
On 24-8-2004 17:16, JMM wrote:

> I'm having issues dealing with Locale under 1.4.1_03-b02. The problem
> seems to be with the Java Runtime having problems reading the system
> locale. My system locale is set to UK, but when I run a test program
> (code below) I get the date formatted to a US locale instead of UK. I
> ran the same program under 1.4.2_03 on win xp, and 1.4.2_04-b05 on
> win2k which both worked fine. Running the same program under 1.4.1_03
> on win xp and win 2k results in the problem. Does anyone know of a
> workaround to this problem without upgrading to 1.4.2_03 or higher?

Start your program with
java -Duser.language=en -Duser.country=GB ...
Note: GB, not UK


> Also does anyone know what the minimum version we should have if we
> did decide to upgrade JRE's?

Don't know, but I'd go for the latest release of 1.4.2 (which is _05 at the time of this writing).
The release notes normally contain a list of bugs that have been fixed by that release.

> [snip]

--
Regards,
Z.

JMM

unread,
Aug 24, 2004, 5:54:44 PM8/24/04
to
zoopy <zo...@hates.spam> wrote in message news:<412b8612$0$42417$e4fe...@news.xs4all.nl>...


Thanks for the information, but unfortunately I can't upgrade or have
hardcoded command line arguments. The reason is because my users
won't go for the upgrade and they're located all over the world. Do
you know of a workaround that uses the systems locale and the date
formatter will properly use it too?

zoopy

unread,
Aug 25, 2004, 5:49:37 AM8/25/04
to

There's not much that I can think of, considering these restrictions.

You could check the Java bugdatabase to see if there are workarounds for the problem.

As you probably know, you can programmatically change the default locale (Locale.setDefault(...)),
but that maybe would mean that you have to change your program and have the users upgraded (well,
with new version of your program, not the JRE), a way you seemed no to want to go.

Otherwise you could play around with Window's regional settings, and see if that brings a solution.
Yet, then you would have to instruct every user to change their settings, possibly causing problems
with other applications they have. So, this doesn't seem the proper direction either.
--
Regards,
Z.

JMM

unread,
Aug 25, 2004, 10:00:12 AM8/25/04
to
zoopy <zo...@hates.spam> wrote in message news:<412c6087$0$34762$e4fe...@news.xs4all.nl>...

Thanks again for the update. I realized I was incorrect with the
original issue. It seems that the JRE 1.4.1 does pick up the correct
Locale, but either the DateFormat and/or Calendar classes are ignoring
the Locale. Do you have any suggestions/workarounds in getting the
DateFormat and/or Calendar to acknowledge the correct Locale?

Jonathan

zoopy

unread,
Aug 25, 2004, 10:40:54 AM8/25/04
to
On 25-8-2004 16:00, JMM wrote:

> [snip]


> Thanks again for the update. I realized I was incorrect with the
> original issue. It seems that the JRE 1.4.1 does pick up the correct
> Locale, but either the DateFormat and/or Calendar classes are ignoring
> the Locale. Do you have any suggestions/workarounds in getting the
> DateFormat and/or Calendar to acknowledge the correct Locale?
>
> Jonathan

IIRC there's
DateFormat.getDateInstance(format,locale)
and
Calender.getInstance(locale)
--
Regards,
Z.

JMM

unread,
Aug 25, 2004, 4:45:05 PM8/25/04
to
zoopy <zo...@hates.spam> wrote in message news:<412ca4cc$0$559$e4fe...@news.xs4all.nl>...

Thanks for all the assistance. It turns out there wasn't a problem
with any of the classes that I mentioned. The problem was that we're
using the US version of 1.4.1 and not the international version.
Sorry for the mistake.

Jonathan

zoopy

unread,
Aug 26, 2004, 2:06:18 PM8/26/04
to
On 25-8-2004 22:45, JMM wrote:
> Thanks for all the assistance. It turns out there wasn't a problem
> with any of the classes that I mentioned. The problem was that we're
> using the US version of 1.4.1 and not the international version.

Yep, that explains a lot...

> Sorry for the mistake.

Not at all, something to keep in mind for me too ;-)
--
Regards,
Z.

Reply all
Reply to author
Forward
0 new messages