Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

How to get a date object when string("12.8.2003") is passed

Posted on 2003-11-11
Last Modified: 2010-03-31
I have a dateString "08.12.2003". How to get a date object of this?
When I am breaking my sring and passing the values to the date object new Date(2003, 12, 8), it gives me wrong date(time).
Is there anyother way to get a date object.
Question by:balap
  • 3
  • 2
LVL 86

Accepted Solution

CEHJ earned 50 total points
ID: 9721412
SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy");
Date d = sdf.parse("08.12.2003");
LVL 35

Expert Comment

ID: 9721428
>  SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy");

Obviously, if you are from the US (I can't tell from the date you supplied), this should be:

 SimpleDateFormat sdf = new SimpleDateFormat("MM.dd.yyyy");

LVL 86

Expert Comment

ID: 9721436
Is there an echo? ;-)
LVL 35

Expert Comment

ID: 9721456

Sorry :-(

balap, CEHJ is right, don't accept my comment as an answer :-)
LVL 86

Expert Comment

ID: 9721465

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to get all the API from website? 11 104
servlet  URL Rewriting 1 42
reverse digits of a number using for loop 5 52
runtime exception 2 41
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question