Results 1 to 5 of 5
  1. #1
    R O C K Y's Avatar
    R O C K Y is offline Member
    Join Date
    Feb 2009
    Posts
    19
    Rep Power
    0

    Question Problem with Date Object

    Dear all

    Date dob = new Date("02" + "/" + "03" + "/" + "1983");
    DateFormat df = DateFormat.getDateInstance();
    String str = df.format(dob);
    dob = new Date(str);

    System.out.println(str);//Feb 3, 1983
    System.out.println(dob);//Thu Feb 03 00:00:00 IST 1983
    problem:
    I want to store "Feb 3, 1983" in dob but this i get through String object str only.
    Is there any way to store "Feb 3, 1983" in dob as an output rather than "Thu Feb 03 00:00:00 IST 1983".

    I need this because i need to pass the dob object further rather than String object which gives correct result.

    waiting for ur reply..............:)

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Read the API docs for SimpleDateFormat.

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

  4. #4
    toadaly is offline Senior Member
    Join Date
    Jan 2009
    Posts
    671
    Rep Power
    6

    Default

    I recommend SimpleDateFormat as well.

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

Similar Threads

  1. Replies: 2
    Last Post: 12-03-2008, 12:14 PM
  2. Time-Date problem
    By teo.danciu in forum New To Java
    Replies: 5
    Last Post: 08-27-2008, 11:01 AM
  3. java new Date() problem
    By nanaji in forum Advanced Java
    Replies: 2
    Last Post: 08-04-2008, 09:08 AM
  4. Creating a Gregorian Calendar using a Date object gives date - 1
    By prachi_goliwadekar in forum New To Java
    Replies: 1
    Last Post: 05-08-2008, 09:32 PM
  5. problem with date field
    By Ed in forum JDBC
    Replies: 2
    Last Post: 06-12-2007, 05:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •