Article View: borland.public.jbuilder.java.language
Article #450Re: Newbie Date question (but trickier than it looks)
From: Hugh Jones
Date: Tue, 04 Oct 2005 07:37
Date: Tue, 04 Oct 2005 07:37
39 lines
2086 bytes
2086 bytes
Gillmer J. Derge [TeamB] wrote:
> Try something like this:
>
> Locale klugedDateFormatLocale = new Locale("x", "y", "z");
> Locale originalDefaultLocale = Locale.getDefault();
> Locale.setLocale(klugedDateFormatLocale);
> try {
> // evil 3rd party API call
> } finally {
> Locale.setLocale(originalDefaultLocale);
> }
>
Thanks for that.
Sorry if I am being obtuse, but I really am new to java.
I can see how your code creates a new Locale, caches the default,
applies the new one, then restores the default.
What I can't see is how I set klugedDateFormatLocale's dateFormat. This
is the bit I couldn't find in the docs.
I had kind of assumed that I could do something like the following
tempLocale = new Locale("ENGLISH","UK");
*tempLocale.setDateFormat("dd/MM/yyyy");*
savedLocale = Locale.getDefault();
Locale.setLocale(tempLocale);
try {
// Evil stuff
} finally {
Locale.setLocale(savedLocale);
}
Thanks again.
Hugh
Technical Details
Message-ID:
<434230c1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!212.101.4.254.MISMATCH!solnet.ch!solnet.ch!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<434142fe$1@newsgroups.borland.com> <43414798$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: f74b3,597975fc8535d7af X-Google-Attributes: gidf74b3,public X-Google-Language: ENGLISH,ASCII-7-bit Date: Tue, 04 Oct 2005 08:37:38 +0100 From: Hugh Jones <Hugh.Jones@No_spammmers_Mail.Thomson.com> User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: borland.public.jbuilder.java.language Subject: Re: Newbie Date question (but trickier than it looks) References: <434142fe$1@newsgroups.borland.com> <43414798$1@newsgroups.borland.com> In-Reply-To: <43414798$1@newsgroups.borland.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 81.144.179.98 Message-ID: <434230c1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1128411329 81.144.179.98 (4 Oct 2005 00:35:29 -0700) Lines: 39 Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!212.101.4.254.MISMATCH!solnet.ch!solnet.ch!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail