Solved

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

Posted on 2003-11-11
5
298 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
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 …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

747 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

12 Experts available now in Live!

Get 1:1 Help Now