Results 1 to 4 of 4
  1. #1
    Sno's Avatar
    Sno
    Sno is offline Senior Member
    Join Date
    Apr 2010
    Posts
    196
    Rep Power
    5

    Default Parsing Java Date

    Hey Guys,

    I have a date that is formatted like this 2010-11-22T00:00:00

    I am attempting to parse it into java date.

    For the past hour I've tried different SimpleDateFormats using the api yet I keep throwing java.text.ParseException: Unparseable date: "2010-11-22T00:00:00".

    Java Code:
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-dd-MMM", Locale.US);
    Date crtDate = sdf.parse(dt);
    System.out.println(crtDate);
    Does anyone happen to know the solution to this, or must I concatenate the date?
    :rolleyes: ~ Sno ~ :rolleyes:
    '-~ B.S. Computer Science ~-'

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,874
    Rep Power
    8

    Default

    You are creating a formatter that will parse yyyy-dd-MMM but you are attempting to parse yyyy-dd-MM'T'hh:mm:ss with it. At least I'm guessing that's what you're trying to do.

    SimpleDateFormat (Java Platform SE 6)

  3. #3
    Sno's Avatar
    Sno
    Sno is offline Senior Member
    Join Date
    Apr 2010
    Posts
    196
    Rep Power
    5

    Default

    so I should perform
    Java Code:
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-dd-MM'T'hh:mm:ss", Locale.US);
    Date crtDate = sdf.parse("2010-11-22T00:00:00");
    Than I should be able to format crtDate anyway I want?
    :rolleyes: ~ Sno ~ :rolleyes:
    '-~ B.S. Computer Science ~-'

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,874
    Rep Power
    8

    Default

    Quote Originally Posted by Sno View Post
    so I should perform
    Java Code:
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-dd-MM'T'hh:mm:ss", Locale.US);
    Date crtDate = sdf.parse("2010-11-22T00:00:00");
    Than I should be able to format crtDate anyway I want?
    What happened when you tried that?

Similar Threads

  1. java.util.Date vs java.sql.Date
    By Jack in forum New To Java
    Replies: 5
    Last Post: 10-28-2010, 02:59 PM
  2. parsing date problem
    By jackjosh_in in forum Advanced Java
    Replies: 7
    Last Post: 05-21-2010, 02:06 PM
  3. parsing date
    By jackjosh_in in forum New To Java
    Replies: 2
    Last Post: 05-21-2010, 01:07 PM
  4. Replies: 1
    Last Post: 05-31-2009, 06:48 PM
  5. Parsing URL in Java
    By Java Tip in forum java.net
    Replies: 0
    Last Post: 04-07-2008, 08:14 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
  •