DateFormat parse() method

Discussion in 'Java' started by chirs, Apr 5, 2004.

  1. chirs

    chirs Guest

    Hi,

    Could you show me how to use DateFormat parse() method to parse a date
    "January 1, 2004". A small example is all I need.

    Thank you very much.

    Chris.
     
    chirs, Apr 5, 2004
    #1
    1. Advertising

  2. chirs

    P.Hill Guest

    P.Hill, Apr 6, 2004
    #2
    1. Advertising

  3. chirs

    chirs Guest

    "P.Hill" <> wrote in message news:<c4tcbt$eb3$>...
    > chirs wrote:
    > > Could you show me how to use DateFormat parse() method to parse a date
    > > "January 1, 2004". A small example is all I need.

    >
    > See lots of listed under "Examples" at:
    >
    > http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html
    >
    > But how about "MMMMMMM dd, yyyy"?
    >
    > -Paul


    What I want is not to format a date into "MMMMMMM dd, yyyy". The
    "input" is a string
    such as "January 1, 2004" or "July 12, 2004", I need a Date object as
    an "output". I looked at the link, but I could not find an example of
    doing this. Thank you.
     
    chirs, Apr 6, 2004
    #3
  4. chirs

    Bryce (Work) Guest

    On 6 Apr 2004 11:07:51 -0700, (chirs) wrote:

    >"P.Hill" <> wrote in message news:<c4tcbt$eb3$>...
    >> chirs wrote:
    >> > Could you show me how to use DateFormat parse() method to parse a date
    >> > "January 1, 2004". A small example is all I need.

    >>
    >> See lots of listed under "Examples" at:
    >>
    >> http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html
    >>
    >> But how about "MMMMMMM dd, yyyy"?
    >>
    >> -Paul

    >
    >What I want is not to format a date into "MMMMMMM dd, yyyy". The
    >"input" is a string
    >such as "January 1, 2004" or "July 12, 2004", I need a Date object as
    >an "output". I looked at the link, but I could not find an example of
    >doing this. Thank you.


    You didn't look hard enough. hint, look for the "parse" function of
    SimpleDateFormat.

    --
    now with more cowbell
     
    Bryce (Work), Apr 6, 2004
    #4
  5. chirs

    Bryce (Work) Guest

    On 6 Apr 2004 11:07:51 -0700, (chirs) wrote:

    >"P.Hill" <> wrote in message news:<c4tcbt$eb3$>...
    >> chirs wrote:
    >> > Could you show me how to use DateFormat parse() method to parse a date
    >> > "January 1, 2004". A small example is all I need.

    >>
    >> See lots of listed under "Examples" at:
    >>
    >> http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html
    >>
    >> But how about "MMMMMMM dd, yyyy"?
    >>
    >> -Paul

    >
    >What I want is not to format a date into "MMMMMMM dd, yyyy". The
    >"input" is a string
    >such as "January 1, 2004" or "July 12, 2004", I need a Date object as
    >an "output". I looked at the link, but I could not find an example of
    >doing this. Thank you.


    awww hell... I'll just tell you.

    String dateString = "January 1, 2004";
    String dateFormatString = "MMMMMMM dd, yyyy";

    SimpleDateFormat format = new SimpleDateFormat(dateFormatString);

    Date newDate = format.parse(dateString);

    --
    now with more cowbell
     
    Bryce (Work), Apr 6, 2004
    #5
  6. chirs

    asimali2002

    Joined:
    Mar 6, 2007
    Messages:
    1
    DateFormat eg.

    Here is a simple eg:

    Code:
    DateFormat df = new SimpleDateFormat("YYYY-MM-DDThh:mm:ss.sTZD");
    String sDate = df.format(date);
    Date newDate = df.parse(sDate);
    but i have a problem here, newDate again not in the format passed.

    Thanks
    Asim
     
    asimali2002, Mar 6, 2007
    #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. Phil
    Replies:
    0
    Views:
    614
  2. Grant Merwitz
    Replies:
    2
    Views:
    577
    Grant Merwitz
    Aug 18, 2005
  3. Jun

    DateFormat

    Jun, Jan 6, 2004, in forum: Java
    Replies:
    1
    Views:
    526
    Chris Smith
    Jan 6, 2004
  4. Sting
    Replies:
    2
    Views:
    356
    Thomas Weidenfeller
    Feb 19, 2004
  5. KAR120C
    Replies:
    5
    Views:
    565
    Hendrik Maryns
    Jan 22, 2006
Loading...

Share This Page