Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > format date in java

Reply
Thread Tools

format date in java

 
 
dufffman@gmail.com
Guest
Posts: n/a
 
      11-17-2005
Hi,

Simple java question. If my program takes in a date in the format,
yyyyMMdd, is there anyway I could output this date in java, in the
format, "November 13th 2005".

Thanks,

 
Reply With Quote
 
 
 
 
Oliver Wong
Guest
Posts: n/a
 
      11-17-2005

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> Hi,
>
> Simple java question. If my program takes in a date in the format,
> yyyyMMdd, is there anyway I could output this date in java, in the
> format, "November 13th 2005".
>
> Thanks,
>


See java.text.DateFormat

http://java.sun.com/j2se/1.5.0/docs/...ateFormat.html

- Oliver


 
Reply With Quote
 
 
 
 
Rhino
Guest
Posts: n/a
 
      11-17-2005

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> Hi,
>
> Simple java question. If my program takes in a date in the format,
> yyyyMMdd, is there anyway I could output this date in java, in the
> format, "November 13th 2005".
>

You probably can't get the 'th' part of the date using existing Java
techniques; I don't think there's any existing method you can use to get the
'th' in '13th' or the 'st' in '1st' or the 'nd' in '2nd'. But you could add
that part yourself with a simple if or switch statement that adds the
appropriate fragment once you've formatted the date as "November 13 2005" or
whatever. As Oliver Wong says in his reply, DateFormat is the approach you
should use. See also the SimpleDateFormat class for an explanation of Date
and Time Patterns.

If your application is going to have an international audience, you might
want to have a look at the Internationalization and Localization trail in
the Java Tutorial; most other countries don't display dates in the "November
13 2005" format.

Rhino



 
Reply With Quote
 
zero
Guest
Posts: n/a
 
      11-17-2005
"Rhino" <(E-Mail Removed)> wrote in
news:WE5ff.3392$(E-Mail Removed):

>
> most other countries don't display dates
> in the "November 13 2005" format.
>


Which can be very confusing - is 05-10-2005 October 5th or May 10th?
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      11-17-2005
On 17 Nov 2005 10:44:34 -0800, http://www.velocityreviews.com/forums/(E-Mail Removed) wrote, quoted or
indirectly quoted someone who said :

>Simple java question. If my program takes in a date in the format,
>yyyyMMdd, is there anyway I could output this date in java, in the
>format, "November 13th 2005".


see http://mindprod.com/jgloss/calendar.html

See SimpleDateFormat
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
 
Reply With Quote
 
Dag Sunde
Guest
Posts: n/a
 
      11-18-2005
"zero" <(E-Mail Removed)> wrote in message
news:Xns9711DB9B4CBAFzerothishi@195.130.132.70...
> "Rhino" <(E-Mail Removed)> wrote in
> news:WE5ff.3392$(E-Mail Removed):
>
>>
>> most other countries don't display dates
>> in the "November 13 2005" format.
>>

>
> Which can be very confusing - is 05-10-2005 October 5th or May 10th?


Which is why you should strive for either nationalize it to the
long string format, or use the ISO Date format.

Ie. (Norway):
13. November, 2005
(US):
November 13 2005

(ISO, any country):
2005-11-13

--
Dag.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting java.util.Date to java.sql.Date mail4sushovan@gmail.com Java 5 05-04-2011 02:59 PM
(Again) java.util.Date vs java.sql.Date grz01 Java 3 09-18-2009 10:55 PM
Convert java.util.Date to java.sql.Date Bumsys@gmail.com Java 5 01-22-2008 04:02 PM
Date, date date date.... Peter Grison Java 10 05-30-2004 01:20 PM
Date Format - best way of converting a string into a date format Brian Candy ASP .Net 2 02-18-2004 02:13 PM



Advertisments