Jeff Hoekstra wrote:
>Default locale is en_GB
>Short pattern is dd/MM/yy
>Medium pattern is dd-MMM-yyyy
>Long pattern is dd MMMM yyyy
>Full pattern is dd MMMM yyyy
>
>I have set my International pref pane Language to British
>English, at the top of the list, and the Date Format is
>United Knigdom. The input method is British.
>
>Unfortunately my dates continue to display inaccurately.
For your test program, which produced the given output, the default Locale
is obviously correct. The pattern strings also seem to be correct.
However, since you didn't post any source, nor the improperly formatted
date outputs, there's no way to tell what's actually going on, because we
don't know what code is executing.
Please post the source of the Java program that is printing your Short
pattern, Medium pattern, etc. Also post your code that fails to print the
dates in the proper format, since the output above looks like it works.
The above output may represent a test-case, but since its output is
correct, it isn't a fail-case.
If isolating a fail-case causes it to start working, then the problem is
something in the larger program's environment. For example, you might be
programmatically setting the default Locale somewhere. Or there might be
missing resources for the "en_GB" Locale, since DateFormats are loaded from
resource-bundles, and a Locale is just a key. It's hard to say what's
wrong, since we don't have source for your fail-case or known-good
test-case.
The following works here, with the output shown after the source. If
you're doing something else, you'll have to tell us exactly what you're
doing by posting the source.
import java.text.*;
import java.util.*;
public class LocaleTrial
{
public static void
main( String[] args )
{
tell( "Default Locale: " + Locale.getDefault() );
Date now = new Date();
describe( now, DateFormat.SHORT );
describe( now, DateFormat.MEDIUM );
describe( now, DateFormat.LONG );
describe( now, DateFormat.FULL );
}
private static void
describe( Date when, int dateStyle )
{
DateFormat format = DateFormat.getDateInstance( dateStyle );
tell( "Format for " + dateStyle + ": " + format.format( when ) );
}
private static void
tell( String text )
{ System.out.println( text ); }
}
## With English at top of Languages list:
Default Locale: en_US
Format for 3: 6/14/05
Format for 2: Jun 14, 2005
Format for 1: June 14, 2005
Format for 0: Tuesday, June 14, 2005
## After moving British English to top of Languages list:
Default Locale: en_GB
Format for 3: 14/06/05
Format for 2: 14-Jun-2005
Format for 1: 14 June 2005
Format for 0: 14 June 2005
-- GG
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden
This email sent to email@hidden