format date in java

Discussion in 'Java' started by dufffman@gmail.com, Nov 17, 2005.

  1. Guest

    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,
     
    , Nov 17, 2005
    #1
    1. Advertising

  2. Oliver Wong Guest

    <> wrote in message
    news:...
    > 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/api/java/text/DateFormat.html

    - Oliver
     
    Oliver Wong, Nov 17, 2005
    #2
    1. Advertising

  3. Rhino Guest

    <> wrote in message
    news:...
    > 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
     
    Rhino, Nov 17, 2005
    #3
  4. zero Guest

    "Rhino" <> wrote in
    news:WE5ff.3392$:

    >
    > 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?
     
    zero, Nov 17, 2005
    #4
  5. Roedy Green Guest

    On 17 Nov 2005 10:44:34 -0800, 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.
     
    Roedy Green, Nov 17, 2005
    #5
  6. Dag Sunde Guest

    "zero" <> wrote in message
    news:Xns9711DB9B4CBAFzerothishi@195.130.132.70...
    > "Rhino" <> wrote in
    > news:WE5ff.3392$:
    >
    >>
    >> 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.
     
    Dag Sunde, Nov 18, 2005
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brian Candy
    Replies:
    2
    Views:
    1,210
    Janaka
    Feb 18, 2004
  2. DC
    Replies:
    5
    Views:
    3,038
    Brendan Reynolds
    Jul 1, 2005
  3. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,380
    Michael Borgwardt
    May 30, 2004
  4. Chu
    Replies:
    3
    Views:
    4,242
    Shawn
    Aug 15, 2006
  5. Josh Sharpe
    Replies:
    1
    Views:
    229
    Brian Candler
    Sep 21, 2010
Loading...

Share This Page