Solved

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

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
recursion example 16 124
sites similar to codingbat to improve coding hanson skills 3 49
eclipse argument 14 60
rhino JavaScript import, load 25 82
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
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.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

785 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