Solved

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

Posted on 2003-11-11
5
307 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
  • 3
  • 2
5 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 50 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
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.
The viewer will learn how to implement Singleton Design Pattern in Java.
This video teaches viewers about errors in exception handling.

867 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now