🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #303

Re: Newbie Date question (but trickier than it looks)

#303
From: Arthur Ore
Date: Tue, 04 Oct 2005 13:27
33 lines
1990 bytes
If you can pass you dates as Strings then you can format the date as below

SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd_HH:mm:ss");
String x = sdf.format(new java.util.Date());

Arth

>
> 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: <434282d2$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!pd7cy2so!shaw.ca!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <434142fe$1@newsgroups.borland.com> <43414798$1@newsgroups.borland.com> <434230c1@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
From: "Arthur Ore" <nospamthx@nospamthx.co.uk>
Newsgroups: borland.public.jbuilder.java.language
References: <434142fe$1@newsgroups.borland.com> <43414798$1@newsgroups.borland.com> <434230c1@newsgroups.borland.com>
Subject: Re: Newbie Date question (but trickier than it looks)
Date: Tue, 4 Oct 2005 14:27:42 +0100
Lines: 35
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
X-RFC2646: Format=Flowed; Response
NNTP-Posting-Host: 82.69.65.131
Message-ID: <434282d2$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1128432338 82.69.65.131 (4 Oct 2005 06:25:38 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!pd7cy2so!shaw.ca!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail