13 Replies Latest reply: Nov 26, 2008 11:48 PM by 843785 RSS

    Unable to create Date from String

    843785
      I want to convert a string to a Date object. Here's my code

      String ds = "20080101";
      DateFormat df = DateFormat.getDateInstance();
      try {
      Date d = df.parse(ds);
      }
      catch(ParseException e) {
      System.out.println("Unable to parse " + ds);
      }

      I got the java.text.ParseException: Unparseable date: "20080101" error.

      Do you have any ideas? Thanks