Results 1 to 5 of 5
  1. #1
    newbiejava is offline Senior Member
    Join Date
    Jan 2010
    Posts
    138
    Rep Power
    0

    Default Unparseable date

    Hello All,

    I need to convert string to date format (yyyy-MM-dd)
    but it gives me java.text.ParseException: Unparseable date "24-Jul-07"

    what I missed?

    Java Code:
    String str_date="24-July-07";
    DateFormat formatter ;
    Date date ;
    formatter = new SimpleDateFormat("yyyy-MM-dd");
    date = (Date)formatter.parse(str_date);

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,371
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by newbiejava View Post
    Hello All,

    I need to convert string to date format (yyyy-MM-dd)
    but it gives me java.text.ParseException: Unparseable date "24-Jul-07"

    what I missed?

    Java Code:
    String str_date="24-July-07";
    DateFormat formatter ;
    Date date ;
    formatter = new SimpleDateFormat("yyyy-MM-dd");
    date = (Date)formatter.parse(str_date);
    Your date is in another format: dd-MMM-yy but your DateFormat object expects a date in the format yyyy-MM-dd.

    kind regards,

    Jos

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

  4. #4
    newbiejava is offline Senior Member
    Join Date
    Jan 2010
    Posts
    138
    Rep Power
    0

    Default

    I meant I want to convert from "24-Jul-07" to "2007-07-24" .. any idea?

  5. #5
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,371
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by newbiejava View Post
    I meant I want to convert from "24-Jul-07" to "2007-07-24" .. any idea?
    Sure, use two DataFormat objects; one to parse a String in one format and the other one to produce a String in the other format.

    kind regards,

    Jos

Similar Threads

  1. want the first date and last date of each month
    By javastuden in forum New To Java
    Replies: 3
    Last Post: 02-24-2010, 10:31 AM
  2. julian date to full date format
    By judy318 in forum New To Java
    Replies: 7
    Last Post: 11-02-2009, 12:17 PM
  3. Compare date input to database with current date
    By hungleon88 in forum Advanced Java
    Replies: 2
    Last Post: 11-25-2008, 08:10 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, 08:32 PM
  5. Difference between current date and anothe date
    By vijay balusamy in forum New To Java
    Replies: 1
    Last Post: 04-16-2008, 04:15 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
  •