Why Java SimpleDateFormat().parse() is printing weird formate?

Posted by MAK on Stack Overflow See other posts from Stack Overflow or by MAK
Published on 2010-03-21T09:35:47Z Indexed on 2010/03/21 10:11 UTC
Read the original article Hit count: 426

My input is String formated as the following:

3/4/2010 10:40:01 AM
3/4/2010 10:38:31 AM

My code is:

DateFormat dateFormat = new SimpleDateFormat("dd/mm/yyyy hh:mm:ss aa");
            try
            {
                Date today = dateFormat.parse(time);
                System.out.println("Date Time : " + today);

            }
            catch (ParseException e)
            {
                e.printStackTrace();
            }

the output is:

Sun Jan 03 10:38:31 AST 2010
Sun Jan 03 10:40:01 AST 2010

I'm not sure from where the day (Sun) came from? or (AST)? and why the date is wrong? I just wanted to keep the same format of the original String date and make it into a Date object.

I'm using Netbeans 6.8 Mac version.

© Stack Overflow or respective owner

Related posts about java

Related posts about datetime