?
Solved

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

Posted on 2003-11-11
5
Medium Priority
?
332 Views
Last Modified: 2010-03-31
Hello,
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.
regards,
balap
0
Comment
Question by:balap
[X]
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
  • 3
  • 2
5 Comments
 
LVL 86

Accepted Solution

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

Expert Comment

by:TimYates
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");

;-)
0
 
LVL 86

Expert Comment

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

Expert Comment

by:TimYates
ID: 9721456
hehehehe...

Sorry :-(

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

Expert Comment

by:CEHJ
ID: 9721465
:-)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses
Course of the Month13 days, 9 hours left to enroll

801 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