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,
Oliver Wong - 17 Nov 2005 18:50 GMT
> Hi,
>
[quoted text clipped - 3 lines]
>
> Thanks,
See java.text.DateFormat
http://java.sun.com/j2se/1.5.0/docs/api/java/text/DateFormat.html
- Oliver
Rhino - 17 Nov 2005 20:23 GMT
> 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
zero - 17 Nov 2005 20:35 GMT
> 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?
Dag Sunde - 18 Nov 2005 09:28 GMT
>> 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

Signature
Dag.
Roedy Green - 17 Nov 2005 20:47 GMT
>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

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.