Results 1 to 3 of 3
  1. #1
    hahncj55408 is offline Member
    Join Date
    Aug 2011
    Posts
    7
    Rep Power
    0

    Default SimpleDateFormat not reading my month

    Hi Guys,
    I'm struggling with the SimpleDateFormat class.
    No matter what date I enter, it always reads january instead of the proper month.
    Can you guide me in the right direction?

    Here is a sample:
    Java Code:
    		
    
                    Date date;
    		SimpleDateFormat df = (SimpleDateFormat)SimpleDateFormat.getDateInstance();
    		df.applyPattern("yyyy-MM-DD HH:mm:ss");
    		date = df.parse("2011-09-14 09:54:00");
    		System.out.println(date.toString());
    The results:
    Fri Jan 14 09:54:00 CST 2011

    I'm sure its a simple mistake, but I just don't see it.

    Thanks,
    Chris

  2. #2
    kaarefin is offline w3processing.com
    Join Date
    Sep 2011
    Location
    Norway
    Posts
    3
    Rep Power
    0

    Default Re: SimpleDateFormat not reading my month

    The pattern must be "yyyy-MM-dd HH:mm:ss" .

  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
    19

Similar Threads

  1. SimpleDateFormat Problem
    By UnfairBear in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 09-12-2011, 10:50 AM
  2. JTextField and SimpleDateFormat
    By mine0926 in forum New To Java
    Replies: 15
    Last Post: 07-06-2010, 03:10 AM
  3. JFormattedTextField + SimpleDateFormat
    By Ralphw in forum AWT / Swing
    Replies: 1
    Last Post: 07-07-2009, 10:53 AM
  4. Locale with SimpleDateFormat
    By swati.jyoti in forum New To Java
    Replies: 4
    Last Post: 07-02-2009, 02:34 PM
  5. Using SimpleDateFormat
    By Java Tip in forum Java Tip
    Replies: 1
    Last Post: 07-18-2008, 08:33 AM

Posting Permissions

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